An Overview Of IIS 7.5 Feature HTTP Redirect

This redirection helps in a website migration, so that any request to old websites can be redirected to new websites at IIS level or in redirecting all traffic on HTTP to HTTPS without writing code. We can do this redirection at server level for all requests or at specific website level as well.

Let’s open IIS 7.5 manager and check whether HTTP Redirect module is present or not under IIS section as shown below:

section

If it doesn't exist, we can install the same by going “Turn on or off Windows Feature” in Control Panel and selecting same.

feature

Let’s select “Default Web Site”, double-click on HTTP Redirect and understand its settings:

redirect

We enabled “Redirect requests to this destination” and entered www.microsoft.com URL to which all requests will be redirected from Default Web Site.

When I browse http://localhost, it will redirect.

url

We can configure HTTP status code to:

301 Permanent – It will return HTTP response code as HTTP/1.1 301 Moved Permanently.

302 Found - It will return HTTP response code as HTTP/1.1 302 Redirect. This will inform client to issue a new request to the location specified in the destination attribute.

307 Temporary - It will return HTTP response code as HTTP/1.1 307 Redirect and prevents the client from losing data when the browser issues an HTTP POST request.

We can check “Redirect all requests to exact destination”, which will redirect to exact destination as entered.

We can check “Only redirect requests to content in this directory”, which will limit redirection to destination URL's root folder only, not subfolders. For example, if it is enabled and destination URL and request will be redirected.

Instead of IIS Manager, we can use appcmd.exe to configure it with below command:

C:\Windows\System32\inetsrv>appcmd.exe set config "Default Web Site" -section:system.webServer/httpRedirect /enabled:"True" /exactDestination:"True" /httpRespon
seStatus:"Found" /destination:www.test.com.


dos

This feature remains the same in IIS 8, 8.5 and above settings will still apply. We can use URL Rewrite 2.0 module for advanced configuration of redirection.

I am ending things here on HTTP Redirect, I hope this article will be helpful for all.
Read more articles on Servers: