1. Home
  2. Presales
  3. Is it possible to setup 301 Permanent redirection for same site through IIS?
  1. Home
  2. Presales
  3. Is it possible to setup 301 Permanent redirection for same site through IIS?

Is it possible to setup 301 Permanent redirection for same site through IIS?

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.

Updated on April 14, 2020

Was this article helpful?