在我的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|bbd+|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。