5

我已经编写了一个规则来基于用户代理重定向请求。该规则设置为将默认请求(非移动)重定向到Domain1移动设备和来自移动设备的请求到移动域,Domain2.

即使在应用了移动重定向之后,来自移动设备的所有请求都会被带到Domain1.

请参阅下面的重定向规则。谁能告诉我我错过了什么?

<rewrite>
  <rules>
    <rule name="Mobile UA redirect" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_USER_AGENT}" pattern="^.*BlackBerry.*$ " />
        <add input="{HTTP_USER_AGENT}" pattern=".*Mobile.*Safari" />
      </conditions>
      <action type="Redirect" url="Domain2" />
    </rule>
    <rule name="Claritinchallenge to" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <action type="Redirect" url="Domain1" appendQueryString="false" />
    </rule>
  </rules>
</rewrite>
4

1 回答 1

7

在您的Mobile UA redirect规则中,条件逻辑分组是默认情况下的一个:MatchAll

我不认为有HTTP_USER_AGENT匹配的手机^.*BlackBerry.*$也会匹配.*Mobile.*Safari。因此,您需要将逻辑分组更改为MatchAny.

您的规则将是:

<rule name="Mobile UA redirect" enabled="true" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAny">
    <add input="{HTTP_USER_AGENT}" pattern="^.*BlackBerry.*$ " />
    <add input="{HTTP_USER_AGENT}" pattern=".*Mobile.*Safari" />
  </conditions>
  <action type="Redirect" url="MobileURL" />
</rule>
于 2013-04-09T15:20:33.047 回答