簡體   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