.htaccess 使用htaccess将移动用户从root/[x]重定向到root/mobile/[x]
我正在使用以下代码重定向移动用户:.htaccess 使用htaccess将移动用户从root/[x]重定向到root/mobile/[x],.htaccess,mobile,.htaccess,Mobile,我正在使用以下代码重定向移动用户: #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/f
#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,我需要此规则来应用于移动用户尝试访问的任何页面。这应该满足您的要求:
#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]
谢谢您能告诉我如何从这个规则中排除文件吗?假设我想让移动用户和桌面用户都使用相同的.php?