Solved

DNS non-www forward to www domain

Posted on 2009-04-01
22
3,328 Views
Last Modified: 2012-05-06
Hi

I have a domain name www.domainname.com but if people go to the website via domainname.com without the www at the front then I want them to be redirected to www.domainname.com.

Is this possible in Windows 2003 dns?  If so what records do i need in order to get this working?

I have the following records in DNS (note not real IP address)::
www  A  127.0.0.1

ftp  A 127.0.0.1

mail   A  127.0.0.1

pop  A  127.0.0.1

smtp  A  127.0.0.1

Open in new window

0
Comment
Question by:Padresangel
  • 8
  • 5
  • 4
  • +2
22 Comments
 
LVL 10

Expert Comment

by:Michael Ian Claridge
ID: 24038976
Hello,

You can add a forward lookup in your DNS with the IP address and the instance of the site without WWW which should work.

Cheers

Michael
0
 

Author Comment

by:Padresangel
ID: 24039003
Hi Michael,

What would the entry look like to do that?  Sorry new to DNS and have to set this up!

Kind regards,

Lindsay
0
 
LVL 10

Expert Comment

by:Michael Ian Claridge
ID: 24039033
I believe all the answers are here:-

http://www.experts-exchange.com/Networking/Protocols/DNS/Q_24276556.html

Cheers

Michael
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 24039068

The record looks like this:

(same as parent folder)  A  <IPAddress>

You get that by leaving the name box blank when creating a Host (A) record.

Bear in mind that this will not redirect them to www.domain.com, the URL they enter will stay as http://domain.com.

And it's perhaps worth noting that if this happens to be an Active Directory domain name then you will not be able to make this change.

Chris
0
 

Author Comment

by:Padresangel
ID: 24039141
Hi

So what you are saying is that I cannot redirect domainname.com to www.domainname.com via DNS? I suppose i will have to do this in the website code.

Kind regards,

Lindsay
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 24039179

Basically yes.

DNS will deal with getting the name to an IP Address (either directly with Host (A) or via another name with Alias (CNAME)), but it cannot change the URL entered in the browser, only a web server can do that.

Chris
0
 
LVL 10

Expert Comment

by:Michael Ian Claridge
ID: 24039190
Hello,

If you have your website with IP for example 10.0.0.1 which is www.mysite.com users can access the site yes?
When users enter mysite.com it does not, if you setup the forward lookup so when a user enters mysite.com which you have specified within your DNS forward lookup it will show the site hosted at 10.0.0.1 (the address of your web site as www.mysite.com)

This should work.

Hope this helps, sorry if it is unclear.

Regards

Michael
0
 
LVL 10

Expert Comment

by:Michael Ian Claridge
ID: 24039207
Ahh, sorry the penny has just dropped, been working in a domain infrastructure for too long apparently.
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 24039224

> it will show the site hosted at 10.0.0.1

I would add that while the request may show up at the server (10.0.0.1) that doesn't necessarily mean it will show up at the site (www.domain.com). Whether it does or not depends on how the site is hosted.

For example, if you use shared hosting with an ISP you would need to contact them to have them add "domain.com" as a Host Header so the request is directed to correct site. Otherwise the request is directed to the default site (or dropped).

Whether or that that applies here depends very much on how the website is hosted.

Chris
0
 

Author Comment

by:Padresangel
ID: 24039332
Hi

Ok so I cannot do this in DNS...... both addresses work and point to the same website... Chris you mentioned only a web server can do what i want to do.... I have a dedicated server so I can make the necessary changes.... Do I need to setup a new IIS website and then forward it to the www.domainname.com IIS record in order to do what i want or is there an easier way to do this in IIS?

Thanks for your help so far!

Lindsay
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 125 total points
ID: 24039387

You have a few options, and setting up a new site is certainly one of them. You would just create a new site with "domain.com" as a Host Header, and have it redirect to "www.domain.com". That may well be the easiest option.

Other possibilities include testing the URL value in code (ASP, ASPX, PHP, or whichever your favourite is), then redirecting based on that.

Chris
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Padresangel
ID: 24039411
Hi

Thanks Chris I created another site just for domainname.com and did a redirect to www.domainname.com and it worked!  Simple really just thought I could do it in DNS instead!

THanks

Lindsay
0
 

Author Closing Comment

by:Padresangel
ID: 31565293
Thanks Chris, see my last comment!
0
 

Expert Comment

by:ITGeneral
ID: 25142573
Could he not have just deleted the www A record and recreated it with a blank?
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 25142689

That wouldn't redirect, which was the original requirement for this. Only web servers (something responding to HTTP requests) can redirect, DNS cannot.

Chris
0
 

Expert Comment

by:ITGeneral
ID: 25142709
I see, but if he had control over his DNS then he could have done so?
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 25142721

No. You cannot redirect in DNS at all, it's not a matter of control, it's a completely different protocol.

Chris
0
 
LVL 1

Expert Comment

by:jmateknik
ID: 34358331
I think that what you wanted was to create a CNAME-record that points an empty string to FQDN www.domain.com (?)
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34358517

A CNAME record (establishing an Alias) does not redirect, nothing you do in DNS will change a value typed into a browser.

Chris
0
 
LVL 1

Expert Comment

by:jmateknik
ID: 34358588
I have customer networks that fail to get to there external homepage when they dont type www before domain.com, because i had to make the zone domain.com in their dns (for mail, autodiscover and remote a-records).

I stumbled upon this this thread trying to solve this issue via DNS records, and found that creating a CNAME record solved my problem. I suppose its not a redirect, but its a solution.


0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34358639

Yeah, it'll get you to the server, it makes a name resolve to the same IP as the aliased name. In the context of this thread it won't work because the expectation is that it will also transparently change the value typed into the address bar, something only a web server can do.

Chris
0
 
LVL 1

Expert Comment

by:jmateknik
ID: 34359043
In that case it was very good that you (as always) were attentive/alert, so that noone gets misguided. Why is it always you running with all the glory? [smiling]
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
Resolve DNS query failed errors for Exchange
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now