www.example.com showing a 404 error while example.com is working when set up through cPanel

by Dean Meehan   Last Updated October 31, 2017 15:04 PM

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.



Answers 2


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)

dan
dan
September 20, 2013 00:43 AM

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]
Ivo van der Veeken
Ivo van der Veeken
September 20, 2013 12:58 PM

Related Questions



Redirecting all child pages from subdomain

Updated June 23, 2016 08:01 AM


Sub-Domain Redirect Loop .htacess

Updated July 15, 2015 13:01 PM