Redirect IIS URL重写+;重定向+;与查询字符串不匹配

Redirect IIS URL重写+;重定向+;与查询字符串不匹配,redirect,iis,url-rewriting,iis-7.5,iis-10,Redirect,Iis,Url Rewriting,Iis 7.5,Iis 10,当url包含www.且查询字符串与特定值不匹配时,我需要重定向到另一个网站。不管情况如何,我总是被重定向 <rewrite> <rules> <rule name="Redirect to Landing Page" stopProcessing="true"> <match url="(.*)" />

当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
  • 请求uri是
    /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>


希望这有帮助

{HTTP_Host}
仅表示
www.dev.MyWebpage.com
不是完整的url。这对你有意义吗?谢谢你的更新,但我仍然能够重定向,无论条件如何“/>了解如何编辑问题以包含新信息。还要学习如何调试规则,如何检查路径信息或请求URI是否正确empty@AbhilashMuttalli可以使用正则表达式,如下所示