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!
Related Posts:
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?
jagdish Says:
September 19th, 2008 at 9:59 am
Hi
on my site I want to redirect all the pages to new site except the home page.
We are moving our site to new Domain but want the home page of the old site still running. Is it possible from IIS setting ?
Thanks
jagdish
Ryan Guest Says:
October 7th, 2008 at 8:41 am
Hi Dave,
I have tried setting the rediect for both the default web site and the localhost to “/owa” and “https://webmail.MYDOMAIN.com/owa” however, neither seem to work. Do I need to alter any premissions or is there something else I’m missing?
Any help would be greatly appreaciated.
Regards,
Jason Says:
November 13th, 2008 at 11:21 am
Jerry,
Great article! I have completed the redirects from non-www. to www. for canonicalization reasons. I am also trying to redirect the /index.asp page to always be loaded as the .com page, with no index.asp.
I am attempting to do this to complete the canonicalization on my site. I have no problems achieving this result on apache servers but I have not found a solution on IIS servers. The problem that I am running into is that a 301 redirect from index.asp to just .com puts the query into a loop.
I would greatly appreciate any insight or suggestions into how to rectify this issue.
Thanks again Jerry, for the insightful article you have written!
ed0g Says:
November 18th, 2008 at 11:55 am
Ryan Guest,
I don’t remember the exact details, but OWA is written in IIS6 classic mode, and the redirect module has to be added to that view somehow, or it is not possible. This is because of how OWA is written…
Not much help, but perhaps just enough to get it started (it being a google search)
Anthony Says:
December 16th, 2008 at 2:41 pm
Nice post! Just what I needed for a http to https redirect. The overview of the different types of redirects was very helpful. Thanks.
Brian Knoblauch Says:
February 26th, 2009 at 1:29 pm
This is exactly what I need to do, but I don’t have the “HTTP Redirect” icon! All the rest of them are there, but the redirect is missing.
David Lawlor Says:
February 26th, 2009 at 3:55 pm
Brian-
HTTP redirection might not be enabled by default, you will have to enable it on the webserver. If you have command line access:
Run a command prompt as Administrator
Type: cd \windows\system32\inetsrv
Hit enter
Type: appcmd set config /section:httpRedirect /enabled:true
Hit enter
It may require a restart of IIS service. If you are using a hosted shared solution you will need to contact them to enable this.
Hope that helps.
Dave
Sam Says:
March 12th, 2009 at 8:50 am
In IIS6, when redirecting all pages to a new domain, I had to use server variables. This made sure links to dynamic pages were handled correctly.
E.g., I’d create a permanent redirection to a URL and use two server variables: $S and $Q like so…
http://www.newdomain.com$S$Q
Would I need to use the same variables in IIS7? Or are dynamic pages handled automatically?
Thanks for the great article!
-Sam
Sam Says:
March 12th, 2009 at 9:16 am
I made a mistake in my post above… I used the variable $V (not $S). So the example URL should be http://www.newdomain.com$V$Q
Cort Says:
March 24th, 2009 at 2:30 pm
I’m really having problems with this. I redesigned an html website in aspx. So now I have two websites; an old html and a new aspx – copies except for the redesign and new directories, etc. At this point the old website (hosted by one host) is now pointed at the new website (on a different host).
I’ve tried the redirect (this and others) several times without success. I selected an html file in the old website – redirected it to the appropriate file in the new website – carefully following the procedure – and nothing happened. I’m really sketchy on this but if I’m changing settings on IIS on my computer why would they communicate to the remote site on my hosts server? I don’t publish them to the remote host – the only thing I publish to the remote server is my website. How do they get there? (I’m a novice obviously)
In any case I’ve been completely stuck. If anyone has any ideas please let me know.
Bob Says:
May 26th, 2009 at 12:20 am
Brian, go into Server Manager and look in the IIS section. you will see a section called “role services”. You will see in there that HTTP redirection is not installed. This was the case with mine (windows 2008 x64 and domain controller). You can then install it from there.
Mohamed Fki Says:
July 11th, 2009 at 4:31 am
I do not see the HTTP REDIRECT in IIS7 manager. how do to install it. Thanks in advance.
Yves Germain Says:
July 15th, 2009 at 8:48 am
Add a comment that if you don’t see HTTP redirection in Windows 2008, you have to add the role in IIS 7.0
Kumaravelan Says:
October 19th, 2009 at 10:56 pm
Thankyou dude…
Dave Koehler Says:
November 11th, 2009 at 9:36 am
Hello,
I hope you can spend a few minutes looking at a rather unique issue I’m having with IIS 7 on a Windows Server 2008 machine.
We develop our websites using Cold Fusion and Flex. Because some of the data our
clients store in our databases is sensitive, we have a Secure Certificate
installed on the directory …/inetpub/sslroot. All our secure clients
websites reside under sslroot. In order to access the certificate, a user
logging into a site, say, at …/inetpub/sslroot/ClientSite/loginfile.cfm
must be redirected back to …/inetpub/sslroot. I have setup the redirect to a physical location somewhere other than under inetpub/sslroot. I have put the redirect to …/inetpub/wwwroot/ClientSite (I’ve tried other locations as well). The IIS 7 web.config file correctly shows where the redirect actually goes. In this case it goes to https://securecertificatename.companyname.com/ClientSite.
That all works just fine. A person goes to the website, gets the login
screen from ClientSite and logs in. This is where the trouble begins. A
Flash screen appears that needs to access some cfc files located in a
directory at …inetpub/sslroot/ClientSite/cfc but, instead, it looks for
the files at …inetpub/wwwroot/ClientSite/cfc and because those files are
not there, an error is thrown.
The trouble is that all this works just fine using IIS 6 and that’s why I think it’s an IIS 7 issue and not Flex or Coldfusion.
Any help would be greatly appreciated.
Dave Koehler
Charles Says:
November 25th, 2009 at 7:49 pm
Excellent info. All the other sites talked about scripting the 301 redirect, which is a bit dirty, when you have access to the IIS console!
Cheers.
nidhi tiwari Says:
December 10th, 2009 at 6:29 am
if we created web.config in client’s site then how to use it for redirection of www url to non www url or vise versa.
hein Says:
December 14th, 2009 at 5:53 am
HTTP Redirect is missing on my IIS7 on window server 2008. Do I need to install this seperately or ?
Tabassum Says:
January 10th, 2010 at 11:49 pm
Hi,
It’s a great article, but my issue is that how to redirect between virtual pages i.e I have a page in aspx(~/sample.aspx) and I used URL rewriting for that page now the new url is something like ~/sample/sample.html which is rewrite to ~/sample.aspx now I want that
if user type the url ~/sample.html or ~/sample.aspx then the url is redirected to ~/sample/sample.html.
Please guid me on the above issue
LIZ Says:
May 21st, 2010 at 2:00 pm
HTTP Redirect was missing on my IIS7 as well. I opened Web Platform Installer 2.0, went to web platform and clicked customize under web server, I was able to install http redirect from there.
TransParent57 Says:
June 22nd, 2010 at 9:03 am
Hi.
I have a website that has – as its default virtual directory – a login page. The user types in their username and password and then clicks on a Login button. Once the user is verified, it also enables one or more thumbnail buttons on the updated login page (it is now at “Step 2: User is logged in and is waiting for the user to click on a thumbnail button for the desired application for a redirect of the current web page). Each of these thumbnails redirects to individual virtual directories (one per separate web app).
We have this working on an older web server with IIS 6 with no problems. Now that we are going to a newer web seerver (Windows Server 2008 and IIS 7), I cannot seem to get the info on how to allow one web site to redirect to multiple other web sites depending on the user’s selection. The articles that I have seen so far deal with redirecting one web site to one other web site. That is not what I need.
Any and all help is greatly appreciated.
Thanks.
Hot Custard Says:
July 14th, 2010 at 3:37 pm
Thanks Liz for pointing out its an add-on in Web Platform Installer, i was wondering why i couldnt find it.
SuperMike Says:
July 18th, 2010 at 7:23 pm
I’ve been looking for an article like this for two days.
Thank very much.
Michael in San Diego
Julie Cheung Says:
July 26th, 2010 at 5:02 am
I’ve been looking for a complete step by step instruction on 301 redirecting on IIS 7 server. I find redirects straightforward to do on Apache servers but never knew how to with IIS, this is excellent, thanks! :) Julie
Internet Marketing Says:
August 4th, 2010 at 4:22 am
Hi Dave,
Thanks for the details but I have a query please?
I’m attempting to redirect a non-www (http://example .com) to a www site (http://www.example.com, but when I update the http redirect settings on the non-www site, it also sets the same settings on the www site.
Any ideas why this might be happening? Best Regards, Brad
Michael R. Murphy Says:
August 10th, 2010 at 10:48 am
Dave,
Thanks for this info. A client recently upgraded to SBS and I wasn’t familiar with setting up redirects in their new version of IIS. This was a life saver.
-MRM
Keone Says:
August 22nd, 2010 at 11:51 am
to install the redirect option in IIS7, start Server manager, right click on Web Server (IIS), choose “Add Role Service”, expand “Commonn HTTP Features”, choose “HTTP Redirection” and install
-Keone
Benny Hauk Says:
August 26th, 2010 at 1:37 pm
@Internet Marketing:
The reason changing the HTTP Redirect setting for one site affects the other site is because setting that setting actually drops a config file into the folder where that site resides which handles the redirect. IIS6 didn’t work that way so both Web Sites could point to the same folder (the redirect site doesn’t need a “folder” anyway, right?). Basically, create an empty folder like inetpub\redirect1 and put the redirect site there. You’ll have to create a new folder for each redirect site you have (you can’t have all your redirect sites “share” a common inetpub\redirect folder. Here’s more detail that basically says the same thing:
http://www.zeroonezero.com/design/programming/iis-7-is-annoying/
AspDotNetStorefront Migration and 301 Redirects | Demac Media Says:
August 30th, 2010 at 9:53 pm
[...] Console. There are tons of articles on the web explaining how to do this, so I’ll just kindly link to one with nice pictures and walk thrus on how to accomplish [...]