How can I redirect all traffic which is NOT on a mobile device?

Posted by Chris`, 01-06-2008, 07:44 AM
Hey WHT! I have another question. I've finally got a mobile website working, and I tested it on my phone and it works fine. It's for some forums, so it's fairly complicated. So, I'm just stuck on one last thing! Basically, members can load the site, login, navigate around and post, etc.. And it changes their skin to the "Mobile Skin" when they login from the mobile login page. But the problem is that if they login later on their computer, then they're still in the mobile skin! So, I need to find a way to redirect all traffic which is not using a mobile browser to the default skin. This would also prevent people using the skin just to hide all my ads or something. I was thinking of tricky ways to get this done, but I don't know the code for any of it.. sadly. Would it be possible to redirect a user based on their screen resolution, browser type or User Agent for mobile users? It needs to redirect users who are NOT on their mobile device.. Haha. Thanks, ~Chris`

Posted by phporaclehosting, 01-07-2008, 12:57 PM
put all your pages through php parser using addtype, and check the user agent and redirect accordingly

Posted by Steve_Arm, 01-07-2008, 01:14 PM
Take this list http://en.wikipedia.org/wiki/List_of..._mobile_phones and using the $_SERVER['HTTP_USER_AGENT'] you can redirect properly. Example for blackberry: Well regex would be better here, but that's a start.

Posted by stdunbar, 01-08-2008, 02:45 PM
Use the WURFL library. Depending on your implementation language there are many different ways to access the library. Take a look at the WURFL homepage for more information.

Posted by jmichalicek, 01-08-2008, 09:09 PM
WURFL, as suggested, or you can probably also check the accept header to see if it includes wml or not. If it includes wml it's probably (but not 100% guaranteed) mobile. If it doesn't include wml, it's probably not a mobile device.

Posted by Xeentech, 01-09-2008, 10:02 PM
Building on what Steve suggested, you can accomplish the same in a mod_rewrite rule set, example: Based on this you could even direct phones with lesser WAP or XHTML support some where else. What I use is sightly different, though more complex. Most mobile devices send a link to their 'UAProf' (User Agent Profile). This is an XML file that documents the capabilities of the device. Wikipedia page on UAProf Example XML file from one of my phones (SE K770i) If I haven't already got the relevent file/db record cached the site downloads the XML and queries it for the relevent stats then stores them in a more convenient format (MySQL db) and discards the XML (lots of info I don't need). I use the screen size and supported video codecs to know what to send the phone/handset.

Ця відповідь Вам допомогла?

 Роздрукувати цю статтю

Також прочитайте

Error handling in ASP.NET

Posted by Beach Musician, 09-08-2008, 11:49 AMI'm trying to help a colleague who wants to do...

PHP Mail Help

Posted by Danny159, 02-08-2011, 10:19 AMHey, I have the following script, and I am trying to...

Any way to stop spammers from forging the "From" or "Reply To" fields?

Posted by mifbody, 03-28-2008, 07:21 PMHey guys, Is there any possible way to stop spammers from...

Apache eating Memory

Posted by andrei155, 04-20-2009, 10:31 PMApache is wasting away a bit over a GB of memory at...

Please help me with Plesk and Qmail

Posted by biggies, 04-21-2009, 11:30 AMHi, I have server running Plesk 8.6 with Qmail....