简体   繁体   中英

How to redirect a url to another url using web.config?

I would like to redirect https://www.test.com/flights/economy-class-flights to https://www.test.com/flight-types/economy-class

And I tried something like below and it didn't work.

<rule name="Redirect 1" stopProcessing="true">
    <match url="https://www.test.com/flights/economy-class-flights" />
    <action type="Redirect" url="https://www.test.com/flight-types/economy-class" /></rule>

This worked for me.

<rule name="redirect RedirectURL1" stopProcessing="true">
    <match url="^flights/economy-class-flights" ignoreCase="true" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(www.)?test.com" />
    </conditions>
    <action type="Redirect" url="/flight-types/economy-class" redirectType="Permanent" />
</rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM