James Evans
James Evans

Reputation: 197

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

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!

Upvotes: 13

Views: 23675

Answers (2)

mike
mike

Reputation: 2308

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.

Upvotes: 10

spoulson
spoulson

Reputation: 21591

What you need is URL rewriting. There are a number of options. Some are discussed in this question:

IIS URL Rewriting vs URL Routing

Upvotes: -1

Related Questions