【问题标题】:IIS7 and 301 permanent redirects using the location tag in web.configIIS7 和 301 使用 web.config 中的位置标记进行永久重定向
【发布时间】:2011-02-02 13:20:28
【问题描述】:

我需要在 IIS 下运行的 ASP.NET MVC 应用程序的 web.config 中设置一些 301 永久重定向。

最简单的方法是在 web.config 文件中添加类似于下面的标签:

 <location path="TheMenu.aspx">
        <system.webServer>
            <httpRedirect enabled="true" destination="menus/" httpResponseStatus="Permanent" />
        </system.webServer>
    </location>

当我访问http://domain.com/TheMenu.aspx 的站点时,它会将我重定向到http://domain.com/menusxd 而不是http://domain.com/menus

这是什么原因造成的?

【问题讨论】:

标签: asp.net-mvc iis-7 web-config


【解决方案1】:

抱歉,&lt;httpRedirect&gt; 无法为您提供帮助,但您尝试过/您可以使用 IIS7 URL Rewrite 模块吗?

您的规则如下所示:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="TheMenu" patternSyntax="Wildcard" stopProcessing="true">
                <match url="TheMenu.aspx" />
                <action type="Redirect" url="menus/" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

HTH,
查尔斯

【讨论】:

    猜你喜欢
    • 2012-02-24
    • 2011-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-24
    • 2013-07-17
    • 1970-01-01
    相关资源
    最近更新 更多