2012-04-17 94 views
0

我用下面的代碼片段在我的htaccess請求: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請求並仍然重定向它們?

回答

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] 

它將疏通/移動和你的Ajax請求工作。