2012-03-16 78 views
0

我使用以下代碼來重定向移動用戶:從根重定向移動用戶/ [X]爲root /移動/ [X]使用htaccess的

#mobile redirect 
RewriteCond %{REQUEST_URI} !^/mobile/.*$ 
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera  mobile|palmos|webos|googlebot-mobile" [NC] 

事情是,此每一頁重定向到主頁面,例如通過移動設備訪問www.site.com/folder/page將重定向到www.site.com/mobile。我想編輯代碼,以便將相同的頁面導向www.site.com/mobile/folder/page,並且我需要此規則來申請移動用戶嘗試訪問的任何頁面。

回答

1

這應該做你想要什麼:

#mobile redirect 
RewriteCond %{REQUEST_URI} !^/mobile/.*$ 
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera  mobile|palmos|webos|googlebot-mobile" [NC] 
RewriteRule ^(.*)$ /mobile/$1 [R=301,L] 
+0

謝謝!你能告訴我如何從這個規則中排除文件嗎?說我想要same.php被移動和桌面用戶使用? – Roy 2012-03-17 18:47:40