繁体   English   中英

IIS7重写规则,对域上的指定页面强制使用小写

[英]IIS7 rewrite rule that forces lower case for specified pages on domain

我正在尝试创建一个IIS7重写规则,该规则对指定页面强制使用小写字母,以便我可以覆盖指向我的网站的区分大小写的入站链接,以避免Google在/ Contact和/ contact等网址上重复内容。 我发现一条规则很好用,除了它包含域中的所有页面,然后您可以指定要排除的页面。

<rule name="Lower Case Rewrite" enabled="true" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{URL}" pattern="/ordering/shoppingcart/" negate="true" />
</conditions>
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>

可以反转规则,以便除了我在规则中指定的页面之外,该规则不应用于小写字母。 我想要这样做的原因是,在实施规则并且站点太大而无法检查所有页面和处理程序调用时,管理员,购物车和站点的其他部分都失败了。

任何帮助将是巨大的!

<rewrite>
    <rules>
        <rule name="LowerCaseRule1" stopProcessing="true">
            <match url="[A-Z]" ignoreCase="false" />
            <action type="Redirect" url="{ToLower:{URL}}" />
        </rule>
    </rules>
</rewrite>

像这样:

<rule name="Lower Case Rewrite" enabled="true" stopProcessing="true">
  <match url=".*[A-Z].*" ignoreCase="false" />
  <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
    <add input="{URL}" pattern="/content/" />
    <add input="{URL}" pattern="/content2/" />
  </conditions>
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>

使用MatchAny对您的条件进行分组,然后在规则应适用的地方添加所有模式(但请忽略negate属性)。

暂无
暂无

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

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