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.

Was this answer helpful?

 Print this Article

Also Read

godaddy

Posted by cariani, 09-09-2001, 06:59 PMwww.godaddy.com is the best: 8 - 8.85 $ year for one or...

Elgg - Group Discussions

Posted by jamiedolan, 02-12-2011, 07:20 PMHello; I found a free application called Elgg. It's...

SSL Certificate Queries

Posted by EUK-Steve, 01-13-2008, 06:17 PMHow do SSL Certificates work? I was a bit confused when...

Question about moving from a MSSQL 2000 to MSSQL 2008 database

Posted by user471, 03-03-2010, 04:47 PMHi, I have a site that stores it's data in a MSSQL 2000...

Voxtreme...the best of the best?

Posted by Chaps, 07-22-2002, 06:10 PMYo peops... I have been torn between Voxtreme and MChost...