In this post I will show you how to setup an URL redirect in IIS 7. In this post I will assume you have some working knowledge of IIS.
Open IIS (Start –> Administrative Tools –> IIS Manager)
Expand your Web Server then right click on Sites and choose Add Web Site.
Give the site a name such as domain.com redirect. Be sure to add something to the name so you will know that it is a redirect if you need to reference it later. Put in a path for the web site. Redirects don’t really use the path but IIS won’t let you add the web site without this. I created a directory in the following location: C:\inetpub\redirects. I alwyas create this and use this location to place all of my redirects in. Put in the desired IP address or leave it on all unassigned and click OK.
Now double click on “HTTP Redirect” the properties will appear.
Put a check next to “Redirect requests to this destination:“. Now type in the URL for the website you want this URL to redirect to. For example you would type http://www.domain2.com here. Now when someone types www.domain.com in their web browser it will redirect them to www.domain2.com.
For “Redirect Behavior” I put a check next to “Redirect all requests to exact destination” and chose Permanent (301) as my Status Code. These options are further explained below.
- Redirect all requests to exact destination (instead of relative to destination)
Select this option when you want clients to be redirected to the exact URL as specified in the Redirect requests to this destination box.
- Only redirect requests to content in this directory (not subdirectories)
Select this option when you want clients to be redirected to content in only the directory that is specified in the Redirect requests to this destination box.
- Status code
This will specify the redirect status code that is sent to clients:
Found (302): Tells the Web client to issue a new request to the location. This is the default option.
Permanent (301): Tells the Web client that the location for the requested resource has permanently changed. This is also picked up by search engines.
Temporary (307): Prevents a Web browser from losing data when the browser issues an HTTP POST request.
Choose the right options for your scenario. Now click apply on the right hand side.
Make sure your site is started.
That is it now pull up a web broswer and test out your redirect.
Thanks so much for such a detailed article. Very helpful–nice to have to look in ONE place for the answer!