2012-03-16 75 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