Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 517
James Evans Avatar asked Jun 08 '10 14:06

James Evans


People also ask

How do I redirect to another page in IIS?

In the Home pane, double-click HTTP Redirect. In the HTTP Redirect pane, check the box to redirect requests and enter the destination URL. You can optionally specify any of the following options: Configure the redirection destination to be the exact destination as entered.

Can you redirect a URL to a specific page?

Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Choose the desired domain, fill in the URL you want to redirect to another and add the URL of the new page destination. When ready, click Create.


1 Answers

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.

like image 73
mike Avatar answered Oct 14 '22 15:10

mike