自动切换用户到该网站的移动版本 [英] Auto switch user to mobile version of the site

查看:127
本文介绍了自动切换用户到该网站的移动版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置一个重定向,以便在移动设备上的任何身体得到自动转移到该网站的移动版本。 (见下文 - .htaccess文件),但它突然发生,我认为有些人可能实际上要访问的主网站(例如在iPhone或iPad)有没有一种方法能以某种方式设置一个变量,当链接点击点击(并保持该会话),并仍然允许的.htaccess来控制重定向?

如果它可以帮助我们使用 jQuery Mobile的 PHP

任何帮助将是很大的AP preciated。

 的RewriteCond%{HTTP_USER_AGENT}ACS | alav | ALCA |夏新|奥迪| ASTE |阿万|明基|鸟| BLAC | blaz | BREW |电池| CLDC | CMD-[ NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}宕|多科|埃里克| HIPT | INNO | iPAQ的|的Java |夹具| KDDI |克己|纱罗| LG-C | LG-D | LG-G | lge-[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}毛伊岛| maxo | MIDP | MITS | MMEF | MOBI | MOT- |摩托| mwbp | nec- |蝾螈| NOKI | OPWV[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}掌|帕纳|七分裤| pdxg |菲尔|游戏| PLUC |口| PROX | QTEK | qwap |鼠尾草| SAMS |三一重工[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}SCH-|节|发送|斯里| SGH- |沙皮|的西门子|暹| SMaL公司| SMAR |索尼| sph- | SYMB | T-MO[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}特立|时序|胡说| tsm- | upg1 | UPSI | VK-V |沃达| w3cs | wap- |水电局| WAPI[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}WAPP | wapr | WEBC | winw | winw | XDA | xda-[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}up.browser | up.link | windowssce | iemobile |迷你| MMP[NC,OR]
 的RewriteCond%{HTTP_USER_AGENT}塞班| MIDP | WAP手机|口袋|手机| PDA | PSP[NC]
 的RewriteCond%{HTTP_USER_AGENT}!Macintosh的[NC]
 重写规则^(。*)$ http://mobile.mydomain.com/$1 [L,R = 302]
 

解决方案

我以前做过的就是用的mod_rewrite 来还设置cookie:

 的RewriteCond%{} HTTP_COOKIE!FULLSITE = YES
###您当前的情况?
重写规则(。*)http://m.yoursite.com/? [R,L]
 

和我设置cookie FULLSITE 当用户实际点击从移动网站上的查看完整网站链接。

希望有所帮助。

I have a setup a redirect so any body on a mobile device get automatically transferred to the mobile version of the site. (See below - .htaccess file) But it suddenly occurred to me that some people may actually want to visit the main site (e.g on an iphone or ipad) Is there a way can somehow set a variable when a link is click is clicked (and kept for that session) and still allow of the .htaccess to control the redirect?

if it helps we are using jquery mobile and php

Any help would be greatly appreciated.

 RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
 RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]
 RewriteRule ^(.*)$ http://mobile.mydomain.com/$1 [L,R=302]

解决方案

What I have done before is use mod_rewrite to also set a cookie:

RewriteCond %{HTTP_COOKIE} !FULLSITE=yes
### Your current conditions...
RewriteRule (.*) http://m.yoursite.com/? [R,L]

And I set the cookie FULLSITE whenever the user actually clicks the "view full site" link from the mobile site.

Hope that helps.

这篇关于自动切换用户到该网站的移动版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆