[英]IIS URL Rewrite + Redirect + does not match the querystring
當 url 包含 www 時,我需要重定向到另一個網站。 並且查詢字符串與特定值不匹配。 無論情況如何,我總是被重定向
<rewrite>
<rules>
<rule name="Redirect to Landing Page" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_Host}" pattern="www.dev.MyWebpage.com/MCPrivacyNotice" negate="true" />
</conditions>
<action type="Redirect" url="https://www.myWebPage.com" />
</rule>
</rules>
</rewrite>
正如你所描述的,所以你需要在什么時候重定向
www.dev.MyWebpage.com
/MCPrivacyNotice
所以我想這可能是你的答案
<rule name="Redirect to Landing Page" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="www.dev.MyWebpage.com" />
<add input="{REQUEST_URI}" pattern="/MCPrivacyNotice" negate="true" />
</conditions>
<action type="Redirect" url="myWebPage.com" />
</rule>
請注意, logicalGrouping="MatchAll"
以匹配所有條件。 在您的問題和更新中,您使用了logicalGrouping="MatchAny"
這意味着來自域www.dev.MyWebpage.com
每個請求www.dev.MyWebpage.com
將被重定向
還有一件事, /MCPrivacyNotice
是{REQUEST_URI}
或PATH_INFO
而不是QUERY_STRING
你應該選擇正確的模塊。 檢查此詳細信息https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference
希望這可以幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.