Sunday 21 June 2015

Redirect Non-WWW to WWW in Web.config

Here is the URL Rewrite Rule in the IIS web.config file that redirects non-www requests to www requests for your domain name. Make sure you replace with the name of your domain.
        <rule name="Redirect to WWW" stopProcessing="true">
          <match url=".*" />
            <add input="{HTTP_HOST}" pattern="^$" />
          <action type="Redirect" url="{R:0}"
                  redirectType="Permanent" />