There was a problem loading the comments.

Is it possible to setup 301 Permanenet Redirection for same site through IIS

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

In IIS the "301 Redirect Permanent" is not possible if being done to the same site.

There are two possible solutions for this:

Option 1. Setup URL Rewrite

The server supports URL Rewrite. URL Rewrite is somewhat like the Rewrite Module of Apache, but the recipes are quite different.
The reference can be found here: http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference
You can also look up for URL Rewrite recipes for redirecting non-www site to www site.
An example of a URL Rewrite recipe follows:

Add the following code in the <system.webServer> section of your web.config:
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" />
</rule>
</rules>
</rewrite>


Option 2.

The sites domain.com and www.domain.com should be two separate websites.
Then domain.com can contain "301 Redirect Permanent" to www.domain.com.


Share via

Related Articles


Self-Hosted Help Desk Software by SupportPal
© Balasai Net Pvt Ltd