IIS7 and 301 Permanent Redirects
Lets say your launching a new site to replace an old one. You want to make sure that peoples bookmarks and search engine information does not return 404 page not found. The typical way of doing this is to create a 301 permanent redirect on the old file. In IIS6 this was a complete pain. You had to click on every file in the IIS6 manager (before deleting the file) and setup a redirect to the new page. Time consuming and not very good IMO.
IIS7, and its integration with the web.config makes this process so much easier. Look at the example below for an example of how to specify 301 redirects in your web.config file:
<location path="ComputerLab.asp"> <system.webServer> <httpRedirect enabled="true" destination="Labs/" httpResponseStatus="Permanent" /> </system.webServer> </location> <location path="EmailSpamSolution.asp"> <system.webServer> <httpRedirect enabled="true" destination="Support/Spam.aspx" httpResponseStatus="Permanent" /> </system.webServer> </location> <location path="MicrosoftOffice2007.asp"> <system.webServer> <httpRedirect enabled="true" destination="Training/Help/Office2007.aspx" httpResponseStatus="Permanent" /> </system.webServer> </location>
Note: these additions go directly inside of <configuration> and NOT inside of <system.web> or <system.webServer>
















No Comments, Comment or Ping
Reply to “IIS7 and 301 Permanent Redirects”