Saturday, November 7, 2009

IIS Makes Website Redirection Easy

I have found many uses for the redirection functionality that is built into IIS over the years and I am surprised by how many times I come across people using redirect files or other methods to redirect people to new sites or to redirect people to SSL.

Microsoft has some good information here on how to use redirection in IIS. However, I thought I would give some real world examples and provide some screenshots. You will also want to check out this reference to see all of the available parameters. OK, let's get started.

Redirect to SSL

I use IIS redirection the most to redirect regular web traffic to SSL. Here is how:

Example: We want to redirect to SSL. [Site] will be used as a placeholder for whatever you want to call the website in IIS.

Step 1: Set up website called "Redirect [Site] to SSL" (This website will only run on port 80 and will not be assigned a server certificate. You may have to add a host header or assign a specific IP to this site if you are hosting multiple sites.)

Step 2: Now, go to the properties of the site you just created, select the 'Home Directory' tab, select the 'A Redirection to a URL' radio button, under 'Redirect to:' enter ''. For this particular example, you can ignore the check boxes below. However, you may want to use one based on your need and security requirements so do some research.

Step 3: Set up website called [Site] and assign it a certificate so that it will accept SSL connections. (You will either need to add a fake host header, I use 'asdf', or change the TCP port to another number, e.g. 8080 or 1234, so that the sites will not interfere with each other. TCP port is not needed on this site since we want the 'Redirect [Site] to SSL' to respond for HTTP (port 80) traffic.)


Redirect to SSL Exchange 2003 & 2007

Step 1: Follow directions for 'Redirect to SSL', but instead of entering '' in step 2 enter '' (Exchange 2003) or '' (Exchange 2007).

Problem: If someone enters '', no redirection will take place because the traffic is not hitting the redirect site.

Solution: Go to the 'Properties' of the root of your [Site] (the one running SSL) and select the 'Home Directory' tab. Select the 'A Redirection to a URL' radio button, under 'Redirect to:' enter '' (Exchange 2003) or '' (Exchange 2007). Then, check the check box 'A directory below URL entered'. (If you do not check this box, it will apply redirection to all of the sub-directories also. You do not want that.)


Redirect and Preserve Suffix and Parameters (Query String) - Redirection Parameters

Example: You want to redirect '' and '' to '', but you want to make sure that '' or '' redirect to ''. You want to make sure that the redirection preserves the suffix and the parameters

How: Assuming the sites are already set up go to 'Properties' of the site that responds for '' and '', select 'Home Directory' tab, select the 'A Redirection to a URL' radio button, under 'Redirect to:' enter '$S$Q', check 'The exact URL entered above'. When using 'Redirection Parameters', you may (not always) need to check the check box 'The exact URL entered above'. In this example, the box must be checked. $S and $Q are 'Redirection Parameters'.

I won't provide any more examples here, but see the 'Redirect Reference' here to find out more. There are a few more useful parameters and it explains how to use wildcards for more advanced redirection.


  1. Your blog helped me rectify an issue I've been working on intermittently for 2 months.

    Many thanks

  2. you are the champion. After going to production we started getting calls from bookmarked users as it redirected to the base URL and we were able to fix it without loss of time in research and test.

  3. Happy you found what you needed without too much trouble!

  4. What is both domains point to the same site in IIS but want to redirect from one to another.
    MyDomain.Org should do a permanent redirect to , but both pointing to same site.