Apache htaccess重写第二个允许对website.com/m/…的请求。。。保持原样

Apache htaccess重写第二个允许对website.com/m/…的请求。。。保持原样,apache,.htaccess,mod-rewrite,apache2,Apache,.htaccess,Mod Rewrite,Apache2,如果用户试图从手机访问website.com,他们将被重定向到mobile.website.com。但是,mobile.website.com向website.com发出AJAX请求,所以我让所有请求都通过website.com/m/…。这不起作用: # redirect phones/tablets to mobile site RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera

如果用户试图从手机访问
website.com
,他们将被重定向到
mobile.website.com
。但是,
mobile.website.com
website.com
发出AJAX请求,所以我让所有请求都通过
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/…
,则应取消重写规则。有什么想法吗


谢谢

使用以下命令更改代码:

# 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]
另外,如果这仍然不起作用,那么请发布Apache的
access.log
error.log
中的匹配行