繁体   English   中英

仅重定向根文件夹 web.config 上的 default.aspx

[英]Redirect only default.aspx on the root folder web.config

http://foo.com/Default.aspx

http://foo.com/about/Default.aspx

http://foo.com/random/Default.aspx

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

这会将所有 /Default.aspx 重定向到 /

我只需要根目录上的 Default.aspx 重定向到 /。 那怎么办呢? TIA

最后,能够让它工作。

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

patternSyntax="ExactMatch" 是解决问题所需要的。 谢谢你的帮助。

您可以在正则表达式中包含域名而不是 (.*)

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

foo.com/default.aspx 正则表达式测试结果

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM