IIS: How can I redirect requests for one page to another?

20,992

In your web.config do:

<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Foo_To_Bar" stopProcessing="true">
                <match url="^foo.aspx" />
                <action type="Redirect" url="/bar/default.aspx" redirectType="Temporary" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

If you don't want to write the redirects by hand, there is a tool for URL Rewrite and Redirects: http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module The installer says it is for 7.0 but it works with 8.5 as well.

Share:
20,992
James Evans
Author by

James Evans

I write code.

Updated on July 09, 2022

Comments

  • James Evans
    James Evans almost 2 years

    I have written an app to replace a single page and need to redirect the requests for the old page to the new app.

    In IIS, how would I redirect the request for

    http://www.mysite.com/foo.aspx
    

    to

    http://www.mysite.com/bar/default.aspx
    

    Thanks!

  • Barry MSIH
    Barry MSIH over 5 years
    does this work for just \foo.aspx or for any page called foo.aspx?