2

从电话中,如果用户尝试访问website.com,他们将被重定向到mobile.website.com。但是,mobile.website.com向 发出 AJAX 请求website.com,所以我让所有请求都通过website.com/m/.... 这不起作用:

# 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]
RewriteCond %{REQUEST_URI} !^/m/ [NC]
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]

特别是这一行:

RewriteCond %{REQUEST_URI} !^/m/ [NC]

如果 url 匹配,它应该取消重写规则website.com/m/...。有任何想法吗?

谢谢!

4

1 回答 1

1

用这个改变你的代码:

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

此外,如果这仍然不起作用,请从您的 Apacheaccess.logerror.log.

于 2012-04-18T21:44:20.470 回答