Friday, November 10, 2017

URL redirect rule for rewriting non-www to www



You can add below rule by manually in web.config.

In the <system.webServer> section of your web.config, add the following:

<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>