URL rewrite multiple excluded

问题描述:

我正在尝试编写一个IIS Url重写规则,该规则重定向除了两个以外的所有请求,并且我无法弄清楚。URL rewrite multiple excluded

我试图做到: http://server/healthcheck.aspx --> not redirected http://server/idsrv2/2/stuff --> not redirected http://server/stuffstuff --> redirect to http://server/idsrv2/stuffstuff

这是我到目前为止的规则,但它不是在踢: <rule name="Redirect everything to idsrv/2" patternSyntax="Wildcard" stopProcessing="true"> <match url="^$" /> <conditions logicalGrouping="MatchAny"> <add input="{REQUEST_URI}" pattern="^(.*)healthcheck" negate="true"/> <add input="{REQUEST_URI}" pattern="^(.*)idsrv2" negate="true" /> </conditions> <action type="Redirect" url="idsrv2{R:1}" appendQueryString="true"/> </rule>

任何帮助表示赞赏!

您的规则中的逻辑分组应该是MatchAll。我已经改变了你的规则一点,这应该在你的情况下工作:

<rule name="Redirect everything to idsrv/2" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{REQUEST_URI}" pattern="^/healthcheck" negate="true"/> 
     <add input="{REQUEST_URI}" pattern="^/idsrv2" negate="true" /> 
    </conditions> 
    <action type="Redirect" url="idsrv2/{R:0}" appendQueryString="true" /> 
</rule> 
+0

真棒,谢谢!这就说得通了。 – Trondh