2012-04-18 26 views
2

從手機中,如果用戶試圖訪問website.com,則會將其重定向到mobile.website.com。然而,mobile.website.com使得AJAX請求website.com,所以我做的所有請求都通過website.com/m/...。這是行不通的:htaccess RewriteCond讓網站/ 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/...。有任何想法嗎?

謝謝!

回答

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] 

此外,如果這仍然不起作用,那麼請發表您的Apache的access.logerror.log匹配的行。