【问题标题】:IIS: How can I redirect requests for one page to another?IIS:如何将一个页面的请求重定向到另一个页面?
【发布时间】:2011-03-01 05:16:50
【问题描述】:

我编写了一个应用来替换单个页面,需要将旧页面的请求重定向到新应用。

在 IIS 中,我将如何重定向请求

http://www.mysite.com/foo.aspx

http://www.mysite.com/bar/default.aspx

谢谢!

【问题讨论】:

    标签: iis redirect request


    【解决方案1】:

    在您的 web.config 中执行:

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

    如果您不想手动编写重定向,可以使用 URL 重写和重定向工具:http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module 安装程序说它适用于 7.0,但也适用于 8.5。

    【讨论】:

    • 这是否只适用于 \foo.aspx 或任何名为 foo.aspx 的页面?
    【解决方案2】:

    您需要的是 URL 重写。有多种选择。在这个问题中讨论了一些:

    IIS URL Rewriting vs URL Routing

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-08-22
      相关资源
      最近更新 更多