Hello, I am trying to figure out how to redirect my website to a mobile version if the user is on a cellphone. So if someone on a cellphone went to http://example.com it would go to http://m.example.com or http://example.com/m Does anyone have any ideas? Thank You, Jason
Unfortunately, there is no easy way to detect whether the user is on a mobile device. The two biggest options for you are probably DeviceAtlas (commercial) and WURFL (free). A Google search on either of those will point you in the right direction.
Just check the User-Agent, and redirect it to the mobile version. Check out $_SERVER['HTTP_USER_AGENT']
And maybe take a look at the browscap.ini file - it has to be enabled in php.ini, and if you are on a shared hosting, it might not be loaded, but it's a very neat addition if you want to check differences in lots of browsers. You can find the "official" browscap.ini here: http://browsers.garykeith.com/downloads.asp
Yep, this is the best way. Also if you Google "user agent mobile" (w/o quotes) there are pages which will tell you what user-agents to look for.
I have found that a lot of mobile redirecting scripts need to be updated constantly and always include Iphones in the redirecting process. If anyone is interested, I've uploaded a PHP script to the following website: Go to: http://www.pcmechanix.ca/mobile_redirect.htm If you would first like to test the code using a mobile device then input the following url into your mobile browser: http://www.pcmechanix.ca Good Luck!