If you have a website and want to change domain names or if you need to change the architecture of your site, you won’t want visitors following links from other sites and search engines such as Google to get an error while visiting your website.
This can cause visitors to click away and a loss of rankings in the search engines.
Luckily there is a fairly simple and straightforward way to remedy the situation through the use of redirects.
First, let’s look at the different types of redirects that are available in IIS 7:
- 301 – Permanent: This redirect tells the Web client that the location of the requested resource has moved permanently
- 302 – Standard: This redirect tells the Web client to issue a new request to the location specified
- 307 – Temporary: This redirect tells the Web client to resend POST data, which prevents a Web browser from losing data when the browser issues an HTTP POST request
In most circumstances you will want to use a 301 redirect, as this will inform search engines to update their index with the resource’s new location. In some cases a 302 will be appropriate if the change is going to be short term such as a special page that is seasonal.
For this article I will assume that you already have a site setup on a Windows Server 2008 system setup in a web server role, and are familiar with getting into IIS manager.
Redirect to a Different URL
The first and most simple of the redirects will go from one domain to another, useful if you are changing domain names. I have setup the following two domains TSOriginal.com and TSRedirect.com on my test server as you can see:

As you can see, we setup the original domain as TSOriginal.com and have put a simple index.html file in place that looks like this:

Now let’s walk through the steps required to setup a redirect to our target domain TSRedirect.com. If it works correctly then we should see the new index.html page below:

- Open IIS Manager by going to Start -> Administrative Tools -> IIS Manager

- Once IIS Manager opens, expand the WebServer, then the Sites folder, and choose the domain, in this case TSOriginal.com.

- Click on HTTP REDIRECT in the main panel

- Place a check next to Redirect requests to this destination: and fill in the target url in the text box below. In this instance it will be TSRedirect.com.

- In the Redirect Behavior we have several decisions to make about how we want the redirects to work. Let’s explore each of these options.
- Redirect all requests to exact destination – If this object is checked all requests no matter what the original destination will be redirected to the exact location in the text box above. If unchecked everything will be redirected relative to the destination.
- Only redirect requests to content in this directory (not subdirectories) – By default, when you enable redirection, content can be served by subdirectories below the main directory. If you choose this option you can limit requests to just the directory you want without effecting the subdirectories.
- Status Code – In this drop down you choose which status code to return when redirecting. As discussed earlier in this article your options are 301, 302, and 307.
- For this example we will leave everything unchecked and set a status of 301 in the dropdown menu. Click Apply to set the options.

- The changes are now in place and if we navigate to TSOriginal.com it will redirect us to TSRedirect.com.
To test if the 301 status redirects correctly we will use the live HTTP headers plugin for Firefox. It will allow us to see the status codes. Here are the results for the test:

As you can see from the highlighted area the status was returned 301.
All requests now for TSOriginal.com will be sent to TSRedirect.com with a 301 status code relative to the domain name.
Redirect a Single Page to Another Page on the Same Site
This type of redirect is especially useful when you might have some temporary changes to a webpage because of seasonal or holiday changes.
In the case of a seasonal page that will return to normal after a short time, it is best to use a 302 redirect. This lets search engines and other sites know that this change is expected and not to change their index or links.
For this example we have removed the site redirect we had placed on TSOriginal.com, and added two pages of content to the site:
oldpage.html

newpage.html

Now let’s setup a temporary 302 redirect from oldpage.html to newpage.html while.
- Select the site in IIS manager that you want to set the redirect for.
- In the Features window switch to Content View, Right click on the page you want to work with, oldpage.htm in this case, and left click on Switch to Features View

- The page now selected in the Connections Pane, click on HTTP Redirect in the features pane

- Check the box next to Redirect requests to this destination, and fill in the destination page newpage.htm and set the dropdown menu to 302, and click Apply.

- Now if we navigate to the page TSOriginal.com/oldpage.htm we will be redirected to TSOriginal.com/ newpage.htm.
We will again use the Live HTTP Headers plugin for Firefox to view the redirect. As you can see the pages redirect with the correct 302 status code.

You are now ready to do basic redirects in IIS 7 on Windows 2008 server.
These redirects can also be setup using Appcmd.exe at the command line, but this is beyond the scope of this article. If you’re interested check out the Live HTTP plug-in for Firefox.
Want More? Subscribe to our RSS Feed and get all the latest
Server 2008 updates as soon as they’re available!
Tagged:
301 redirect,
302 redirect,
307 redirect,
HTTP Redirection,
IIS 7,
Server 2008,
Windows Server 2008
3 Responses to “HTTP Redirection in IIS 7 on Windows Server 2008”
Leave A Comment:
Jerry Peters Says:
July 28th, 2008 at 2:40 pm
Dave
Good illustration above.
How do I apply this to a 301 redirect from the www version of a site to the non-www version?
Thanks
Jerry Peters
Dave Lawlor Says:
July 28th, 2008 at 3:04 pm
Jerry-
I am glad you liked the article. In IIS if you want to 301 from www to the non www, you have to create each site in IIS and then do the 301 redirect from one to the other.
Make sure to leave “redirect all requests to exact destination” unchecked. You also do not have to populate the www directory with anything, but make sure that if you are using the same IP to remove www from the non-www bindings so that the www site will respond.
Lol that seems a little convoluted let me lay it out in steps:
1) Create www version of site on IIS (no content necessary)
2) Select the www site and click http redirect
3) Check redirect request to this destination and put in non-www value
4) Change status code to 301
5) Click Apply.
6) Make sure that you take the www out of the host name bindings on the non-www site if it is in there. You can check by selecting the non-www site and then click bindings and see if you see the www version in there. If you do go in and remove it. To be sure restart the IIS service, though it may start resiolving without it.
Let me know if you have any problems.
Dave
Jami Says:
August 26th, 2008 at 12:08 pm
thank you! any idea how to set up a 404 page on IIS?