终极移动.htaccess重定向
我已经用下面的.htaccess代码找到了一个不错的移动/桌面重定向解决方案,但是如果有人能提供帮助的话,还有一些增强功能可以让它成为终极解决方案 目录设置: 桌面网站:website.com终极移动.htaccess重定向,.htaccess,redirect,mobile,.htaccess,Redirect,Mobile,我已经用下面的.htaccess代码找到了一个不错的移动/桌面重定向解决方案,但是如果有人能提供帮助的话,还有一些增强功能可以让它成为终极解决方案 目录设置: 桌面网站:website.com 移动网站:m.website.com 启用Cookie的链接: 从桌面站点转到移动站点,将cookie设置为保持移动状态:http://m.website.com?m=1 从移动站点转到桌面站点,将cookie设置为停留在桌面上:http://www.website.com?m=0 当前.htacce
- 从桌面站点转到移动站点,将cookie设置为保持移动状态:http://m.website.com?m=1
- 从移动站点转到桌面站点,将cookie设置为停留在桌面上:http://www.website.com?m=0
RewriteEngine on
# Check if this is the desktop to mobile query string
RewriteCond %{QUERY_STRING} (^|&)m=1(&|$)
# Set a cookie, and skip the next 2 rules
RewriteRule ^ - [CO=mredir:1:%{HTTP_HOST},S=2]
# Check if this is the mobile to desktop query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
RewriteRule ^(.*)$ http://m.website.com/ [L,R=302]
我想补充的是:
RewriteEngine on
# Check if this is the desktop to mobile query string
RewriteCond %{QUERY_STRING} (^|&)m=1(&|$)
# Set a cookie, and skip the next 2 rules
RewriteRule ^ - [CO=mredir:1:%{HTTP_HOST},S=2]
# Check if this is the mobile to desktop query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
RewriteRule ^(.*)$ http://m.website.com/ [L,R=302]
# 1.) Check if on desktop site and having www., if not redirect to www.website.com
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^m\. [NC]
RewriteRule ^(.*)$ http://www.website.com$1 [R=301,L]
2.)除非“/chairs”是一个现有文件(我猜不是),否则mod_rewrite无法完成此操作。因此,我会使用您想要的脚本语言进行检查-例如,在php中:
if (!pageexists($_GET['page']) && $_SERVER['HTTP_HOST'] == 'm.website.com')
header("Location: http://m.website.com/");
where pageexists()是一个您定义的函数,用于检查移动版本中是否有此页面的内容。重新编写引擎打开
重写基/
(6)MeGoGoGoGoGo5+移动电话;avantgo前去去(124)、巴达纳(bada)、黑莓(1244)、黑莓(124)布雷泽(124)黑莓(1240)布雷泽(1240)布雷泽(1240)民方(HTTP)用户(U U U用户)和代理(m)方)方(HTTP)方(用户)的用户(U)方)方(U)方)方)方(HTTP)方(用户)方(用户)方)方(用户)方(U(U)方)方)方)方)方(方)方(方)方(方)方)方(方)方(方)方)方(方)方(方)方)方(方)方)方)方(方)方)方(方)方)方(方)方)方(方)方)方)方(方)方(方)方)方)方)方(方)方)方(方)方)方)方)方)方)方)方(| pocket | psp | series(4 | 6)0 | symbian | treo | up.(浏览器链接)|沃达丰| wap | windows \(ce |电话)| xda | Xino[NC,或]
重写第二方(1-6)方(1-6)方(1-6)方(1-6)方(1-6)方(1-6)方(1-6)方(1-6)方(1-7)方(7)方(HTTP用户(u用户)和代理)方(2)方(1-6)方(1-6)方)方(用户)方(用户)方(用户)方)方(用户)方(用户)方)方)方)方(方)方(方)方)方(方)方)方(方)方(方)方)方(方)方(方)方)方(方)方(方)方)方(方)方(方)方)方(方)方)方(方)方(方)方)方(方)方)方(方)方(方)方)方(方(方)方(方)方)方(方)方)方(方)方)方)方)方)方(方)方非盟(di |本よ)非盟(diよよ)非非盟(diよよ非Q)非非欧元(非非)非非金(diよ非非本よ非非非本よ|本| r)非非本||非非非本|非本|非本|非本|准准准准准(本|非本1244)是(本|去去去去去(本1244)是)是(本|去去去去(去去去去(ck)是)是(ck)是)是(ck)是(ck)是(ck)去去去去(ck)去去去去去(ck)的)去去去(ck)的)去去去去(去的)的;dc-s | devi | dica | dmob | do(c)c(1240)p(c)p)p)o(1240)d(12(12)d)d)d(12(12)c(12(12)c(1240)c(1240)c(c(c)p)c(c)p)p)p)p)o(12(12)d)d)d)d)d(12(12(12)c)a)a(49(12(12)a)a)a)a)和(12(12(12(12(12(12)a)a)a)a)a)a)a)a)和12(12(12(12(12(12(12(12(12)a)a)a)a)a)a)a)的)的)的)的)的)本(12(12(12(12(12(12(12(12(12(12(12)的)的)的)的)的)的)的)的)的)的)的)的)的)的)的(1240)t)t)t)t)t)t)t)t)t)t)t(c)c(c)c(c)c(c)c(c)c(c)c(c)t(124)c(124)c(124)t)t)t)上周四周四周四周四周四)上周四周四,上周四(t)上周四(t)上周日(t)t)上周四(t)惠普(t)惠普(i(i(i(i(i(i)ip)ip)hs-c)c-c-c)c-c(c(c)HC(c)c(c(c)c(c(c)c(c(c(c)c(c(c)c(c(c(c)c(c(c(c(c(((((((((124124124)c)c)c)a(a(((124124124;124;| 124)a)a(a(ja(t | v)a | jbro | jemu | jigs | kddi | keji | kgt(\ |/)|本次调查的结果是,kpt-凯本顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿(第三(第十二十二)乐乐死(第三(第十二)第六)乐乐乐死死(第四)乐死(第三方方在场在场在场在场顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿顿莫(12月12日)本币(12月12日)莫(1月12日)本币(1月12日)本币(1月24日)莫(1月24日)本币(1月24日)莫(1月24日)莫(01日)本币(1月24日)本币(1月24日)本币(01日)本币(01日)本币(01日)本币(01日)本币(01日)本币(12日)两两两两两个本币(12日)本币(12日)本币(12日)本币(01日)本币(01日)本币(12日)本币(01日)本币(12日)本币(12日)本币(12日)本币(本本本周四)本币(12日)本币(本本本周四)本币(12日)本币(12日)本币(12日)本币(本本周四)本币(本本本周四)本币(|wt | nok(6 | i | nzph | o2im | op(ti | wv | oran | owg1 | p800 | pan(a | d | t | pdxg | pg(13)本周四(12-8)岁(13)岁(12-8)岁(12)岁(13)岁(12)岁(13)岁(12)岁(12)岁(12)岁(12)岁(12)岁(12)岁(12)岁(13)岁(13)岁(13)岁(13)岁(13)岁(13)岁(13)岁(13)岁(13)岁(13)岁)岁(12岁)的)本)岁(12岁(12岁)岁(12岁)uc)的)岁(12岁(12岁)岁)岁)大学)的非非非非非非盈利(12岁(12岁(12岁)大学(12岁(12)大学)本本本本本)大学(12岁(12岁(12岁)大学)本本本)本本本本(12岁(12岁(12岁)大学)本)本本)本本)本(12岁(12岁(12岁(12岁(12)本)本)本Ma1240 0|玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛玛尼(((124))))第第(124(124))))第第第第(124124124124(124(124(124))第第第第第第(1241241244(1)第(1244(1241241241244)玛玛玛玛v\)| sy(01 | mb)| t2(18 | 50)| t6(00 | 10 | 18)| ta(gt | lk)| tcl-| tdg-|电话(iよ)m(iよ)m(iよm)m(1244)m(1244)m(1244)m(1244)m(1244)m(m)m)m)m)m)m)m)m(1244)m)m)m(1244)m)m)m)m(1244)m(m)m-m)m)m(m)m)m(1244)m(m)m-m)m(m)m)m)m)m-m)m)m(1244)m(m)m)m)m-m)m)m(1244)m)m)上)m(1244)m)上)m(1244)m)上)m(1244)上)上的蒂姆(1244)m)上的蒂姆(m)蒂姆)蒂姆)蒂姆(m)蒂姆)蒂姆(m)蒂姆(1244)蒂姆(m)蒂81 | 83 | 85 | 98 | w3c | | | | | | | | | | | | | | | | webc | WIT | wi
RewriteRule^$[R,L]我在另一个关于回退重定向的问题上看到了这个帖子,你认为这样的东西对#2?RewriteCond%{DOCUMENT_ROOT}web/$0!-f RewriteRule^ process/[^/]+$web/process/default.php[L]如果“/chairs”的话,我认为这样可以用吗在你的WebBoT中是一个真实的文件。你可以添加一个规则来检查,如果这个文件也存在于移动WebOOT中,如果不是,重定向到主页。你还不满意我的回复吗?请告诉我你错过了什么或者考虑接受它。谢谢!