繁体   English   中英

移动设备的 IIS 重写规则 - 导致循环

[英]IIS Rewrite rule for mobile devices - Causing loop

在我的 IIS 应用程序中有一个内部 url,如果用户通过移动设备浏览,我想重定向客户端。

我尝试了以下 URL 重写规则,它会重定向部分,但也会导致重定向循环过多。

  <rule name="Mobile Rewrite" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="(.*)" negate="false" />
      <conditions logicalGrouping="MatchAny" trackAllCaptures="true">
          <add input="{HTTP_USER_AGENT}" pattern="(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino" />
          <add input="{URL}" pattern=".*MMEducation/ScreenEdRegistration" negate="true" />
      </conditions>
      <action type="Redirect" url="MMEducation/ScreenEdRegistration" appendQueryString="false" redirectType="Found" />
    </rule>

任何人都可以建议我如何使用重写规则解决这个问题?

条件中的{URL}与操作中的url相同。

例如,移动设备发送请求http://example.com/MMEducation/ScreenEdRegistration 它匹配 {URL} 的条件,IIS 会将其重定向到http://example.com/MMEducation/ScreenEdRegistration 重定向后 URL 永远不会改变。 重定向的 URL 仍然符合条件,IIS 将再次重定向..... 循环再循环再循环再循环...

因此,您需要确保重定向的 url 与条件不匹配,以便解决问题。

顺便说一下,你可以参考这个关于如何为移动设备重定向 url。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM