How to resolve canonical issue in .Net

  • Manually in your webconfig file if you are comfortable doing that.

Use this code for redirect default.aspx to main domain:

net

<system.webServer>
<modules runAllManagedModulesForAllRequests=”true”/>
<rewrite>
<rules>
<rule name=”Default Page” enabled=”true” stopProcessing=”true”>
<match url=”^default.aspx$” />
<conditions logicalGrouping=”MatchAll”>
<add input=”{REQUEST_METHOD}” pattern=”GET” />
</conditions>
<action type=”Redirect” url=”/” />
</rule>
</rules>
</rewrite>
</system.webServer>

Use this code for redirect non www to www domain:

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name=”Redirect to WWW” stopProcessing=”true”>

<match url=”.*” />

<conditions>

<add input=”{HTTP_HOST}” pattern=”^yoursite.com$” />

</conditions>

<action type=”Redirect” url=”http://www.yoursite.com/{R:0}” redirectType=”Permanent” />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

Please follow and like us:
0

Add a Comment

Your email address will not be published. Required fields are marked *