htaccess的重定向用户到移动网站,但仍允许从移动网站
问题描述:
我用下面的代码片段在我的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请求并仍然重定向它们?
答
您可以使用:
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请求工作。