【发布时间】:2016-12-06 19:24:28
【问题描述】:
我有一个正在停用的网络应用程序,我正在尝试将所有对旧应用程序的请求重定向到特定页面(其中显示了一个替换链接和一条建议用户更新其书签的消息)。
我已经使用以下问题的答案在 web.config 中设置了 HTTP 重定向:ASP.NET httpRedirect : redirect all pages except one 并且它可以工作,除非用户输入站点根文件夹的 URL 省略了尾部斜杠,在这种情况下它转到树上的下一个目录,例如:
原站点根目录:[domain]/foo/bar/
[domain]/foo/bar/specificpage.aspx 重定向到[domain]/foo/bar/Default.aspx(确定)
[domain]/foo/bar/ 重定向到[domain]/foo/bar/Default.aspx(确定)
[domain]/foo/bar 重定向到 [domain]/foo/Default.aspx(不正常)
这是相关的 web.config:
<system.webServer>
<httpRedirect enabled="true" destination="~/Default.aspx" httpResponseStatus="Permanent">
<add wildcard="/" destination="Default.aspx" />
</httpRedirect>
</system.webServer>
<location path="Default.aspx">
<system.webServer>
<httpRedirect enabled="false" />
</system.webServer>
</location>
当用户转到[domain]/foo/bar时,我怎样才能让它工作?
【问题讨论】:
标签: asp.net iis web-config http-redirect