布尔条件集

时间:2013-06-11 10:51:10

标签: iis mobile iis-7 url-rewriting

我目前正在使用以下规则重写我的移动网站版本的网址:

<rule name="MOBILE example rule" stopProcessing="true" patternSyntax="ECMAScript">
   <match url="^([^/]+)/([^/\.]+)/([^/]+)/([^/]+)/?$" />
   <conditions logicalGrouping="MatchAny" trackAllCaptures="false">                                                                         
      <add input="{HTTP_USER_AGENT}" pattern="mobile|phone" />
      <add input="{HTTP_X-Device-User-Agent}" pattern="mobile|phone" />
      <add input="{HTTP_X-OperaMini-Phone-UA}" pattern="mobile|phone" />                        
   </conditions>
   <action type="Rewrite" url="/mobile/index.php?lang={R:1}&amp;cat={R:2}&amp;brn={R:3}&amp;mdl={R:4}" />
</rule>      

然后,如果用户想要访问网站的“经典”桌面版本,我将“forceNotMobile”cookie设置为“true”。

问题是......我可以添加什么样的条件来解决这个问题:

  • 如果设置了cookie,则规则有效并重写URL;

  • 否则,如果未设置cookie,或等于false,我会停止处理whitout重写任何内容的规则;

我想我正在寻找类似的东西:

<add input="{HTTP_COOKIE}" pattern="forceNotMobile=true" negate="true" />

但是“MatchAny”逻辑分组应该是“MatchAll”,并且不符合我的“ua-is-mobile”规则。

我可以添加两个<conditions />块吗?

PS。是我检查UA移动权的方法吗?我怎样才能改善它?我只希望智能手机能够“重写”到我的移动版本。

0 个答案:

没有答案