Greetings All
I’ve been looking into an effective way to redirect people accessing a niche site via handheld devices, to a focused page for mobile or portable users.
I’ve found sources teaching me how to accomplish this via javascript and php, but post wondered if anybody knew a server side way eg via htaccess file
I have only until now found this : but unsure of the way to use it or whether this is actually the way to take action:
(http: //www. alistapart. com/articles/return-of-the-mobile-stylesheet)
(I understand that recently there’s recently been news that Google advises to never redirect and to help keep people on the identical url, but for this purpose, i do desire to redirect them)
Thank you!
Here’s an added complete version.
Stylesheet type: Put this in a file called ". htaccess" and save that file from the directory with your primary css file (presumably identified as style. css). There it is possible to create a separate file called cellular. css for cellular devices.
RewriteCond %REQUEST_URI! /mobiledirectoryhere/. *$ RewriteCond %HTTP_ACCEPT " text\/vnd\. wap\. wmlapplication\/vnd\. wap\. xhtml\+xml" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " sonysymbiannokiasamsungmobilewindows ceepocopera" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " mininitroj2memidp-cldc-netfrontmotup\. browserup\. linkaudiovox" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " blackberryericsson, panasonicphilipssanyosharpsie-" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " portalmmmblazeravantgodangerpalmseries60palmsourcepocketpc" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " smartphoneroveripaqau-mic, alcatelericyvodafone\/wap1\. wap2\. iPhoneandroid" NC RewriteRule style. css$ mobile. css L, R=301
App type: Put this inside your root directory, afre the wedding of your existing. htaccess file. This can redirect the user to a mobile version of one’s website on any subdomain. If you will not want them to visit the same route, eliminate the $1 from the redirect URL.
RewriteCond %REQUEST_URI! /mobiledirectoryhere/. *$ RewriteCond %HTTP_ACCEPT " text\/vnd\. wap\. wmlapplication\/vnd\. wap\. xhtml\+xml" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " sonysymbiannokiasamsungmobilewindows ceepocopera" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " mininitroj2memidp-cldc-netfrontmotup\. browserup\. linkaudiovox" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " blackberryericsson, panasonicphilipssanyosharpsie-" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " portalmmmblazeravantgodangerpalmseries60palmsourcepocketpc" NC, AND ALSO RewriteCond %HTTP_USER_AGENT " smartphoneroveripaqau-mic, alcatelericyvodafone\/wap1\. wap2\. iPhoneandroid" NC RewriteRule (. *) http: //mobile. mysite. com/$1 L, R=301
Thanks v a lot smoseley v informative just the thing i was looking for So, the css technique above would simply serve a diff stylesheet to users of the people user agents (handheld/mobiles) and not redirect anyone away from your domain
And im remorseful if im currently being slow but can you clarify what you mean by:
Suitable, the CSS edition just serves out an alternative stylesheet for mobile or portable users.
Yep, that was sorts of ambiguous… what I meant is that the $1 is revealing to the redirect to visit the same path in the new domain. So if someone originally stays in http: //mysite. com/whatever. html code they’ll be redirected to http: //mobile. mysite. com/whatever. html code. If you get rid of the $1 they’ll just go to http: //mobile. mysite. com/ it doesn’t matter what path they originally attended in the first site.
I see Thanks greatly. It doesn’t appear to be this will bring about browser issues such as media query procedure (http: //www. alistapart. com/articles/return-of-the-mobile-stylesheet) since it’s server side.. am i in this case
Right, there’s additional control with using this method.