Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I've got a website that works with my custom domain name with the www. but when I type it in without the www. it doesn't show up, and I've had customers wondering if my website is down because of this.

I'd like my website to work with or without the www. whilst still showing the subdomains - eg: www.website.co.uk and www.website.co.uk/contact or website.co.uk and website.co.uk/contact but I can't get it to work without www.

I'm not the most clued up person when it comes to DNS and servers and all that, so if you can give it to me in simple terms that would be great.

I currently have my domain with 123-reg and my DNS forwarding is set up as follows:

@ CNAME website.site.com
www CNAME website.site.com

I also have web forwarding set up as 302 - website.site.com but I think this gets overwritten by the CNAME stuff

Please help me to resolve this as it is so frustrating - but please put it to me in simple terms as otherwise I won't understand!

Thanks so much in advance everyone!!

share|improve this question

migrated from stackoverflow.com Mar 16 '13 at 15:27

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Simon Hayter, Stephen Ostermiller, John Conde Mar 17 '13 at 16:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

webmasterworld.com/website_technology/3454188.htm try a search engine "DNS www and non www" – LastCoder Mar 15 '13 at 18:37

For something like this, who your registrar is doesn't matter. Once you have registered the domain, then you also control all subdomains, including www.

Your DNS settings look correct. Based on your cname settings, your www sub-domain should resolve to the same IP address that your non-www domain resolves to. You can test this by pinging both and checking that the IP address matches:

$ ping website.co.uk
   64 bytes from myhost (
$ ping www.website.co.uk
   64 bytes from myhost (

Make sure the IP addresses given match (the part in my example). If they don't you have a DNS problem.

Once DNS is set up correctly, you have to make sure the webserver is set up correctly. Again, it sounds like you are trying to do the correct thing and have a redirect in place. You say that you use a "302". I would suggest trying to use a "301 permanent redirect". You can test that it is correct by using the following command and seeing a response similar to the following:

$ curl -s -D - http://www.website.co.uk/
    HTTP/1.1 301 Moved Permanently
    Location: http://website.co.uk/
    Content-Type: text/html; charset=UTF-8

    <html><body><p>Moved permanently: <a href="http://website.co.uk/">http://website.co.uk/</a></p></body></html>
share|improve this answer