sim.plified.com

Chris Pollock

Chris Pollock - web developer (PHP/mySQL & ASP.NET)
undivided… my thoughts on world, family, church, business, technology and Jesus Christ (all in all)

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>

 

Technorati Tags: ,,

No Comments, Comment or Ping

Reply to “IIS7 and 301 Permanent Redirects”

Things I see

Emerging LocustEmerging LocustSimonbackgroundSimon - 2 monthsSimon - 2 monthsSimon - 2 monthsSimon - 2 monthsSimon - 2 monthsPlaying in the YardPlaying in the YardPlaying in the YardPlaying in the YardNY to MO to NY GatheringNY to MO to NY GatheringNY to MO to NY Gathering

Chris Pollock

Web Developer - proficient in both PHP and ASP.NET.
Rochester, New York

View my web developement site.

View Chris Pollock's LinkedIn profile

My Pictures

Emerging LocustEmerging LocustSimonbackgroundSimon - 2 monthsSimon - 2 monthsSimon - 2 monthsSimon - 2 monthsSimon - 2 monthsPlaying in the YardPlaying in the YardPlaying in the YardPlaying in the YardNY to MO to NY GatheringNY to MO to NY GatheringNY to MO to NY Gathering