How to create a 301 redirect with a Microsoft IIS server?

The best way to set up a 301 redirect on a website is always to define it directly into your server configuration. This way, you can be certain all your redirect instructions are centralized in a single position and you'll not need multiple editing the day you want to modify them.


Microsoft IIS Server allows you to set up a redirection for a complete domain or just for a single page. Both operations are managed using graphical interface.



Setting up a domain redirect.
In order to set up a redirect for a complete website, you need to configure the complete site profile on your IIS server. To do so, log on your server and select the following command in your usual Windows interface:

Select the server running the site you want to forward. Right click on the site that will be the starting point of your redirection and choose the Properties > Home Directory command. You'll find the following dialog box:





Check the A redirection to a URL option in the first choice list, and then enter the final address of your redirection into the Redirect to text field. Then, check the A permanent redirection for this resource option on the bottom of the box in order to set up the redirection as a 301. Once those settings done, click on the OK button to apply them to your server.



Setting up a page redirect.
The setting of a page redirect is not really different from the domain one. After entering your Internet Service Manager interface, just select the file you wish the redirection to start from, instead of a site profile, and select the Properties command after right-clicking it. The following screen must then be displayed:





As for the domain redirection, check the A redirection to a URL option in the first choice list, and then enter the final address of your redirection into the Redirect to text field. Then, check the A permanent redirection for this resource option on the bottom of the box in order to set up the redirection as a 301. Once those settings done, click on the OK button to apply them to your server.



Setting up a dynamic redirection
As for rewrite rules on an Apache server, IIS interface allows you to set up dynamic redirection. That is to say that the target of a redirection can be set up depending on the located elements of its starting point. In IIS configuration, this system works with generic expressions you'll have to add to your target URL. Each of those generic expressions corresponds to a precise element of the starting URL of the redirect. Fort example, to redirect an address like http://www.old-domain.com/my-folder/my-page.asp to the same path on another domain (for exemple ) http://www.new-domain.com/my-folder/my-page.asp), you'll have to define http://www.new-domain.com/$V as target address, $V standing for the complete path present after the server name on the originally requested page.


Several generic expressions are available for your redirect definition, here are a list of most used ones: