【问题标题】:Redirecting specific default.aspx to / through web.config将特定的 default.aspx 重定向到 / 通过 web.config
【发布时间】:2015-11-02 21:32:30
【问题描述】:

我们的网站结构如下:

http://localhost/default.aspx

http://localhost/aboutus/default.aspx

http://localhost/resources/default.aspx

http://localhost/mobile/default.aspx

当我将以下规则添加到 web.config 时,它将所有 default.aspx 重定向到 /

    <rule name="Default Document" stopProcessing="true">
                <match url="(.*)default.aspx" />
                <action type="Redirect" url="{R:1}" redirectType="Permanent" />
            </rule>

我只希望这些网址中的两个重定向到 /

http://localhost/default.aspx 重定向到http://localhost/

http://localhost/mobile/default.aspx 重定向到http://localhost/mobile/

你能帮忙吗?提前致谢。

【问题讨论】:

  • 有什么建议吗?帮助

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


【解决方案1】:

这是解决方案:

                <rule name="root homemobile" stopProcessing="true">
                    <match url="^mobile/Default.aspx" ignoreCase="true" />
                    <action type="Redirect" url="/mobile/" redirectType="Permanent" />
                </rule>
                <rule name="root home" stopProcessing="true" patternSyntax="ExactMatch">
                    <match url="Default.aspx" ignoreCase="true"  /> 
                    <action type="Redirect" url="/" redirectType="Permanent" /> 
                </rule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 2012-06-29
    • 2020-07-11
    • 2023-03-08
    • 1970-01-01
    相关资源
    最近更新 更多