简体   繁体   English

IIS URL Rewrite + Redirect + 与查询字符串不匹配

[英]IIS URL Rewrite + Redirect + does not match the querystring

I need to redirect to another website when the url contains www.当 url 包含 www 时,我需要重定向到另一个网站。 and the query-string does not match the specfic value.并且查询字符串与特定值不匹配。 I am always getting redirected irrespective of the condition无论情况如何,我总是被重定向

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

As you described, so you need to redirect when正如你所描述的,所以你需要在什么时候重定向

  • Domain is www.dev.MyWebpage.com域是www.dev.MyWebpage.com
  • Request uri is /MCPrivacyNotice请求 uri 是/MCPrivacyNotice

So I think this may be your answer所以我想这可能是你的答案

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

Note that logicalGrouping="MatchAll" to match all condition.请注意, logicalGrouping="MatchAll"以匹配所有条件。 In your question and your update you used logicalGrouping="MatchAny" that means every request from domain www.dev.MyWebpage.com will be redirected在您的问题和更新中,您使用了logicalGrouping="MatchAny"这意味着来自域www.dev.MyWebpage.com每个请求www.dev.MyWebpage.com将被重定向

One more thing, /MCPrivacyNotice is {REQUEST_URI} or PATH_INFO not QUERY_STRING you should choose the right module.还有一件事, /MCPrivacyNotice{REQUEST_URI}PATH_INFO而不是QUERY_STRING你应该选择正确的模块。 Check this for detail https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference检查此详细信息https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

Hope this helps希望这可以帮助

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

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