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

    <location path="oldfile.htm">
            <httpRedirect enabled="true" destination="/newfile.aspx" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />

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.



posted on Friday, March 4, 2011 7:37 PM


No comments posted yet.

Post A Comment