[英]IIS 7.5 URL Rewrite rule to handle request based on user agent
我已经编写了一个规则来根据用户代理重定向请求。 该规则设置为将默认请求(非移动)重定向到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>
在您的Mobile UA redirect
规则中,条件逻辑分组默认为: MatchAll
我认为HTTP_USER_AGENT
匹配^.*BlackBerry.*$
.*Mobile.*Safari
不会也匹配.*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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.