[英]IIS URL Rewrite rule for mobile with “nomobile” cookie
我們正在使用IIS URL重寫模塊通過檢查HTTP_USER_AGENT將所有請求從移動瀏覽器重定向到m.mymobilesite.com。 這可以正常工作,現在我們需要實現一個“查看完整站點”鏈接,該鏈接將允許用戶查看主站點。 嘗試通過在用戶單擊“查看完整站點”鏈接時添加“ nomobile” cookie來實現此目的,該鏈接將由規則進行驗證和否定。 由於某些原因,我的規則似乎不起作用。
請幫忙。
<rewrite>
<rules>
<rule name="MobileRedirect" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_COOKIE}" pattern="nomobile" ignoreCase="true" negate="true" />
<add input="{HTTP_USER_AGENT}" pattern="android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" />
</conditions>
<action type="Redirect" url="http://m.mymobilesite.com" appendQueryString="false" redirectType="Found" />
</rule>
</rules> </rewrite>
規則是完美的,我所描述的對失敗的請求在IIS級別執行跟蹤后想通了這個問題在這里
我在用戶選擇“查看完整站點”鏈接時創建的cookie沒有使用域名創建。 我在cookie創建腳本上添加了domain =“ mymainsite.com”,現在可以正常工作了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.