Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I set up a recent (Wordpress) project on Microsoft Azure with a domain from 123-reg. When I set up the DNS servers I am getting example.com is working to the site, but www.example.com isn't and is showing a 404 error.

If possible I would love to set up the DNS to allow either www.example.com or example.com to work. Even better if both can work!

I have worked with domains before mainly through cPanel which has great options that normally work for me, while doing it straight from the Domain service isn't showing any possible results.

share|improve this question
add comment

2 Answers

When I set up the DNS servers I am getting example.com is working to the site, but www.example.com isn't and is showing a 404 error.

Since you're receiving a 404 error code from a server, that likely means your DNS is configured properly, but your web server is not redirecting to the same content that your non-www (root domain) is returning.

Assuming that your DNS is being managed by the domain registrar 123-reg, you can verify that the DNS for www URLs is pointed to the same IP address that the non-www is pointed to via an A record, as pictured here.

Then if non-www URLs are the preferred ones you've been using or would like to use, you should do a 301 redirect in your web server from: wwww -> non-www.

Lastly, it might be a good idea to tell Google which URL is preferred (i.e., the non-www one). See this for more: Preferred domain (www or non-www)

share|improve this answer
    
How could I for example get www.example.com working only. I'd love example.com to work as well but mainly want the www subdomain to work on the site. –  Dean Meehan Sep 21 '13 at 1:04
    
You would just redirect www to non-www, which is working, and both will return the same content then. Microsoft Azure would likely use IIS, so this might help, but I'd suggest checking the docs for Azure on how to do 301 redirects. –  dan Sep 21 '13 at 1:16
    
After some more digging around, it seems that 301 redirects in Azure are done with web.config. Using my answer here, you might change the lines to modify to pattern="^www.$" /> and remove home/ from url= –  dan Sep 21 '13 at 4:16
    
Perhaps even simpler for you might be to remove the A record for www and instead create a CNAME for www pointed to example.com as pictured in the second part of Example 2 here. –  dan Sep 21 '13 at 4:17
add comment

To ad on Dan's answer: you should put this piece of code in your .htaccess file:

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
share|improve this answer
2  
The OP is hosted on Windows Azure which uses IIS (I'm going to add that tag). But that would be a helpful addition to someone using Apache. –  dan Sep 23 '13 at 0:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.