The life and times of this developer...

WPF, C#, XML and other stuff

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 27 Comments | 0 Trackbacks

News

Twitter












Tag Cloud


Archives

Post Categories

Cool Tools

Friday, March 4, 2011 #

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.

 #