Asp.net 基于多个(但不是全部)条件的IIS重定向规则

Asp.net 基于多个(但不是全部)条件的IIS重定向规则,asp.net,url,iis,redirect,iis-7.5,Asp.net,Url,Iis,Redirect,Iis 7.5,我有一个重写,它被设置为处理多个不同的用户代理,我希望能够在其中任何一个上匹配我的规则。但是,任何匹配其中一个规则的url也必须匹配另一个规则(IP地址)。然而,我找不到任何关于如何做到这一点的文档。有人能对我如何做到这一点提出建议吗 下面是我试图实现的一个例子。我知道这将失败,因为条件节点已经声明了多次 因此,本质上,当任何{HTTP\u USER\u AGENT}规则和任何{REMOTE\u ADDR}规则匹配时,它是一个重定向 <rule name="Mobile UA redire

我有一个重写,它被设置为处理多个不同的用户代理,我希望能够在其中任何一个上匹配我的规则。但是,任何匹配其中一个规则的url也必须匹配另一个规则(IP地址)。然而,我找不到任何关于如何做到这一点的文档。有人能对我如何做到这一点提出建议吗

下面是我试图实现的一个例子。我知道这将失败,因为
条件
节点已经声明了多次

因此,本质上,当任何
{HTTP\u USER\u AGENT}
规则和任何
{REMOTE\u ADDR}
规则匹配时,它是一个重定向

<rule name="Mobile UA redirect" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAny">
    <!-- Any of these can be matched -->
    <add input="{HTTP_USER_AGENT}" pattern="Android" />
    <add input="{HTTP_USER_AGENT}" pattern="BlackBerry" />
    <!-- ... more user agents... -->
  </conditions>
  <!-- Here, similarly, any one of these rules can be matched, but one of the rules above must also match one of the rules below. -->
  <conditions logicalGrouping="MatchAny">
    <add input="{REMOTE_ADDR}" pattern="127.0.0.1" />
    <add input="{REMOTE_ADDR}" pattern="192.168.0.1" />
  </conditions>
  <action type="Redirect" url="http://mob.mydomain.com/{R:0}" appendQueryString="true" />
</rule>


如果您能为我提供帮助,我将不胜感激

下面的smth怎么样,放在底部:

<rule name="MobileRestricted" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAll">
    <add input="{REMOTE_ADDR}" pattern="127.0.0.1" negate="true" />
    <add input="{REMOTE_ADDR}" pattern="192.168.0.1" negate="true" />        
  </conditions>
  <action type="None"/>
</rule>
<rule name="Mobile UA redirect" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAny">
    <!-- Any of these can be matched -->
    <add input="{HTTP_USER_AGENT}" pattern="Android" />
    <add input="{HTTP_USER_AGENT}" pattern="BlackBerry" />
    <!-- ... more user agents... -->
  </conditions>
  <action type="Redirect" url="http://mob.mydomain.com/{R:0}" appendQueryString="true" />
</rule>


没有一条规则,但不超过两条)

你好,谢谢你的回答。我认为这可以奏效。我看到你的手机被限制在IP地址的黑名单上,而不是我的白名单上,但这是一个很简单的改变