How to add a permanent redirect (301) for an htm file in IIS 7
Posted
by bconlon
on Geeks with Blogs
See other posts from Geeks with Blogs
or by bconlon
Published on Fri, 04 Mar 2011 19:37:26 GMT
Indexed on
2011/03/04
23:25 UTC
Read the original article
Hit count: 306
Looking in Web Analytics I could see several external sites pointing at an old .htm file on my web server that no longer existed, so I thought I would get IIS to redirect to the new .aspx replacement. How hard could it be?
This has annoyed me for quite a while today so here is the answer.
1. Install the Http Redirection module - this is not installed by default!!
Windows 7
Start->Control Panel->Programs and Features->Turn Windows Features on or off.
Internet Information Services->World Wide Web Services->Common Http Features->HTTP Redirection.
Windows Server 2008
Start->Administrative Tools->Server Manager.
Roles->Web Server (IIS).
Role Services->Add Role Services.
Common Http Features->HTTP Redirection.
2. Edit your web.config file
<configuration>
.....
<location path="oldfile.htm">
<system.webServer>
<httpRedirect enabled="true" destination="/newfile.aspx" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>
.....
</configuration>
When a user clicks or Google crawls ‘oldfile.htm’ it will get a permanent redirect to ‘/newfile.aspx’ - and should take any Page Rank to the new file.
#
© Geeks with Blogs or respective owner