Admin-Ahead Community

Windows => General Windows => Topic started by: sajugovind on July 26, 2014, 03:13:23 pm

Title: Canonical Redirect using IIS 7.0
Post by: sajugovind on July 26, 2014, 03:13:23 pm
We can see some request that Cx want their domain redirect to WWW always. We can configure the same by adding below code to web.config.

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

Thank you,