Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3436
  • Last Modified:

DNS non-www forward to www domain

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
Padresangel
Asked:
Padresangel
  • 8
  • 5
  • 4
  • +2
1 Solution
 
Michael Ian ClaridgeActing Service Delivery ManagerCommented:
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
 
PadresangelAuthor Commented:
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
 
Michael Ian ClaridgeActing Service Delivery ManagerCommented:
I believe all the answers are here:-

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

Cheers

Michael
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
Chris DentPowerShell DeveloperCommented:

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
 
PadresangelAuthor Commented:
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
 
Chris DentPowerShell DeveloperCommented:

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
 
Michael Ian ClaridgeActing Service Delivery ManagerCommented:
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
 
Michael Ian ClaridgeActing Service Delivery ManagerCommented:
Ahh, sorry the penny has just dropped, been working in a domain infrastructure for too long apparently.
0
 
Chris DentPowerShell DeveloperCommented:

> 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
 
PadresangelAuthor Commented:
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
 
Chris DentPowerShell DeveloperCommented:

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
 
PadresangelAuthor Commented:
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
 
PadresangelAuthor Commented:
Thanks Chris, see my last comment!
0
 
ITGeneralCommented:
Could he not have just deleted the www A record and recreated it with a blank?
0
 
Chris DentPowerShell DeveloperCommented:

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
 
ITGeneralCommented:
I see, but if he had control over his DNS then he could have done so?
0
 
Chris DentPowerShell DeveloperCommented:

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

Chris
0
 
jmateknikCommented:
I think that what you wanted was to create a CNAME-record that points an empty string to FQDN www.domain.com (?)
0
 
Chris DentPowerShell DeveloperCommented:

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

Chris
0
 
jmateknikCommented:
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
 
Chris DentPowerShell DeveloperCommented:

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
 
jmateknikCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 5
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now