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

Own a Server? (Remove Fantastico now)

Posted by BitSurFer, 04-30-2007, 08:31 PMHello EveryOne If you have Fantastico installed in your...

need help grouping a array

Posted by smarty-boots, 10-24-2012, 10:57 AMHi I have this as a array: and I need to group...

Sortable Table

Posted by AvailNetworks, 03-02-2010, 10:42 PMsorry if I sound like a moron when it comes to...

PHP error_logs per site on Windows

Posted by Canadaka, 05-03-2007, 06:34 PMHow does one setup the PHP "log_errors" and "error_log"...

shared nameservers for dedicated server clients`

Posted by Calibaba, 01-13-2008, 09:10 PMIs there a way to use ns1/ns2.yourhostdomain.com for not...