.htaccess ';查看完整站点';将?m=0添加到所有内页
我希望所有内部页面都被重写为?m=0,来自SITEDOTCOM?m=0 所以基本上如果有人用拖尾着陆到整个场地?我希望所有链接都是?m=0 ? 原因:移动重定向完整站点按钮只工作一次。如果用户单击某个对象,则不起作用。返回移动站点 我的代码如下所示.htaccess ';查看完整站点';将?m=0添加到所有内页,.htaccess,mobile,.htaccess,Mobile,我希望所有内部页面都被重写为?m=0,来自SITEDOTCOM?m=0 所以基本上如果有人用拖尾着陆到整个场地?我希望所有链接都是?m=0 ? 原因:移动重定向完整站点按钮只工作一次。如果用户单击某个对象,则不起作用。返回移动站点 我的代码如下所示 RewriteRule ^(.*)\.php$ ^(.*)\.php$?m=0 [R=301,L] 已尝试顶部代码返回无限循环。?想法 这里的这一行: RewriteEngine on RewriteBase / # Check if mobil
RewriteRule ^(.*)\.php$ ^(.*)\.php$?m=0 [R=301,L]
已尝试顶部代码返回无限循环。?想法 这里的这一行:
RewriteEngine on
RewriteBase /
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]
# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile} !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie} !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.Site.com%{REQUEST_URI} [R,L]
也应该检查查询字符串:
RewriteCond %{HTTP:Cookie} !\mobile=0(;|$)
因为cookie在服务器响应之前不会发送到浏览器,所以此时重定向已经完成。两行CO
创建一个cookie发送到浏览器,在收到响应之前,您立即将其重定向到mobile
像这样的怎么样?将重定向规则更改为:
RewriteCond %{QUERY_STRING} !(^|&)mobile=0(&|$)
这对我不起作用,因为移动网站只有2页。添加&使移动站点成为404。因此,我希望htaccess能够访问if,然后如下..单击完整站点“mainsite?m=0”--到达完整站点主页?m=0----然后,如果单击除主页以外的按钮,则除主页以外的所有php页面都应以?m结尾=0@Sparxx“所以我希望htaccess访问if,然后像这样..单击完整站点“mainsite?m=0”,这是什么意思?规则中的
&
仅与查询字符串匹配。它要么是查询字符串的开头,要么是查询字符串的一部分。
RewriteCond %{HTTP:Cookie} mobile=1(;|$)
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ http://m.Site.com%{REQUEST_URI}?mobile=1 [R,L]
RewriteCond %{HTTP:Cookie} \mobile=0(;|$)
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ http://Site.com%{REQUEST_URI}?mobile=0 [R,L]