Tuesday, August 6, 2013

Force website URL to use WWW in ASP.NET


Using the below code in web.config you can force the website URL to always use WWW.

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

No comments:
Write comments
Recommended Posts × +