: Routing or redirecting www.example.com to example.com with IIS What's the safest, and most effective way of redirecting traffic from the www.example.com to example.com or vice versa with IIS?
What's the safest, and most effective way of redirecting traffic from the example.com to example.com or vice versa with IIS?
More posts by @Smith883
3 Comments
Sorted by latest first Latest Oldest Best
Add an A NAME record of * and then your ip address of your hosted server to your DNS settings of your domain name.
For SEO purposes you have to make a decision if you want to go with either example.com (without ) or with example.com and stick with it. Do not use both.
You should set up your DNS to let both point to your web server and bind your website to both host names so that both work in case your visitor types either in his browser.
Then, using the URLRewrite module, you can 301 redirect all traffic to the domain name with or without , whatever you prefer to use for your site.
E.g. if you want to use example.com then you can use the following redirect rule:
<rule name="Force to use example.com stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" negate="true" pattern="^www.example.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com{QUERY_STRING}" appendQueryString="false" redirectType="Permanent" />
</rule>
If you want to use just example.com then use this:
<rule name="Force to use domain.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" negate="true" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="http://example.com{QUERY_STRING}" appendQueryString="false" redirectType="Permanent" />
</rule>
The best way is to do it using DNS entries. That way, your IIS server isn't even involved.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.