0

我在我的 htaccess 中使用以下代码段:

# redirect phones/tablets to mobile site
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]

但是,在我的移动应用程序中,我向 发出 AJAX 请求www.website.com/mobile,但它们都失败了。如何发送这些 AJAX 请求并仍然重定向它们?

4

1 回答 1

1

您可以使用:

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteCond %{REQUEST_URI} !^/mobile [NC]
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]

它将解锁 /mobile 并且您的 ajax 请求将起作用。

于 2012-04-17T15:00:55.250 回答