100% Australian Windows Web Hosting
  • Knowledge Base

Redirect non-www to www 

Was this helpful? (32) (18)

To redirect requests without the www to www on your website, add the following rules to your web.config.
Make sure your.domain.name below is changed to your domain name.
NOTE: If you already have a web.config with rules configured, add the rule below, otherwise a full web.config example is below it.

Rule
=========================================================================

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

Full Web.Config with Rule
==========================================================================


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

 

 

www , non-www , nonwww

 

Last Updated:  5/01/2017 4:51 PM