Results 1 to 6 of 6
-
01-06-2008, 07:44 AM #1Web Hosting Guru
- Join Date
- Mar 2007
- Posts
- 284
How can I redirect all traffic which is NOT on a mobile device?
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`
-
01-07-2008, 12:57 PM #2Newbie
- Join Date
- Dec 2007
- Posts
- 18
put all your pages through php parser using addtype, and check the user agent and redirect accordingly
www.phporaclehosting.com - cheap oracle and php hosting - specialist in php and oracle hosting. from £2.99 a month
-
01-07-2008, 01:14 PM #3Web Hosting Master
- Join Date
- Jan 2006
- Location
- Athens, Greece
- Posts
- 1,481
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:
PHP Code:if ((strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry')) !== false)
{
// set moblie skin
}
-
01-08-2008, 02:45 PM #4Web Hosting Master
- Join Date
- Aug 2002
- Location
- Superior, CO, USA
- Posts
- 635
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.
-
01-08-2008, 09:09 PM #5Newbie
- Join Date
- Dec 2007
- Posts
- 7
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.
-
01-09-2008, 10:02 PM #6Web Hosting Master
- Join Date
- Aug 2005
- Location
- UK
- Posts
- 654
Building on what Steve suggested, you can accomplish the same in a mod_rewrite rule set, example:
Code:RewriteCond %{HTTP_USER_AGENT} BlackBerry|NetFront|SymbianOS|MIDP|WAP2|etc... RewriteRule ^/$ /homepage.max.html
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.