如何使用 web.config 将 url 重定向到另一个 url?

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

我想重定向 https://www.test.com/flights/economy-class-flights to https://www.test.com/flight-types/economy-class

我尝试了类似下面的方法,但没有用。

<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>

这对我有用。

<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>