2017-07-13 106 views
0

我正在嘗試編寫一個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>

任何幫助表示讚賞!

回答

1

您的規則中的邏輯分組應該是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