【问题标题】:How to redirect a url to another url using web.config?如何使用 web.config 将一个 url 重定向到另一个 url?
【发布时间】:2026-02-10 01:05:01
【问题描述】:

我想将https://www.test.com/flights/economy-class-flights 重定向到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>

【问题讨论】:

标签: c# asp.net-mvc web-config


【解决方案1】:

这对我有用。

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

【讨论】:

    最近更新 更多