How do I Redirect my Website to www

To auto redirect permanently for non www URLs to the www equivalent and retain the http(s) protocol you can add the following ot your web.config

NOTE : You should replace with your own domain name.

      <rule name="Redirect to www" stopProcessing="true">
        <match url="(.*)" />
        <conditions trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^$" />
        <action type="Redirect" url="{MapProtocol:{HTTPS}}://www.{HTTP_HOST}{HTTP_URL}" redirectType="Permanent"/>
      <rewriteMap name="MapProtocol">
        <add key="on" value="https" />
        <add key="off" value="http" />

Return to Category