IIS7/8 URL Rewrite ? rewriting non-www to www

In order to Redirect non-www to www on your website, manually edit the web.config file of site and add the following rewrite rule:

<rule name="Redirect example.com to www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<add input="{HTTP_HOST}" pattern="^example.com$" />
<action type="Redirect" url="http://www.example.com/{R:0}" />

Leave a Reply

Your email address will not be published.