: Www.example.com showing a 404 error while example.com is working when set up through cPanel I set up a recent (Wordpress) project on Microsoft Azure with a domain from 123-reg. When I set up
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 example.com isn't and is showing a 404 error.
If possible I would love to set up the DNS to allow either 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.
More posts by @Ann8826881
2 Comments
Sorted by latest first Latest Oldest Best
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 ^(.*)$ example.com/ [L,R=301]
When I set up the DNS servers I am getting example.com is working to the site, but 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)
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.