Www.example.com does not work, but example.com does

This question can also be hosted on ServerFault, however there is definitely a coding element associated with the rewrite rules in my web.config. That's why the question actually has a home on SO.

I recently hosted a site on a new server and found that trying to access my site using www.example.com returns 404, while example.com works just fine. I'm not sure if this is a problem with configuring IIS or with the rewrite rules that I specified in web.config .

I did not update the site without the rules shown below to find out if this is really a problem. These rules worked fine while the site was hosted on DiscountASP.NET.

 <rewrite> <rules> <rule name="Redirect to NON-WWW" stopProcessing="true"> <match url=".*"/> <conditions> <add input="{HTTP_HOST}" pattern="^www.rsolberg.com$"/> </conditions> <action type="Redirect" url="http://rsolberg.com/{R:0}" redirectType="Permanent"/> </rule> <rule name="Default Document" stopProcessing="true"> <match url="(.*)default.aspx"/> <action type="Redirect" url="{R:1}" redirectType="Permanent"/> </rule> </rules> </rewrite> 

I also confirmed to GoDaddy that there is a WWW cname pointing to @.

IN:
http://rsolberg.com

Does not work:
http://www.rsolberg.com

+4
source share
2 answers

I would confirm that IIS has both host headers (rsolberg.com and www.rsolbeg.com) listed for your site. Without requests for a www version, you will be redirected to the correct web server, but IIS will not serve the correct site and may return a generic 404 instead. I don't think redirection / rewriting is involved at all, since no 301/302 are sent.

+1
source

I solved this problem earlier, just delete the previous CNAME. And try adding a new one as shown below.

www.rsolberg.com CNAME → rsolberg.com

  • Ananth Ramasamy Meenachi www.msarm.com
0
source

Source: https://habr.com/ru/post/1301132/


All Articles