Auto switch user to mobile version of the site
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"开发者_StackOverflow社区 [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.
Any reason you dont just use a server-side User-Agent sniff combined with a cookie? I would also seriously consider not automatically sending iPad users to a mobile version - they have a full-featured browser and plenty of space to view your page as a user in a traditional web browser would see it
精彩评论