Over at OSNews, Eugenia Loli-Queru has just updated the OSNews Mobile Detection Kit, a simple PHP script that analyzes visiting browser’s User-Agent headers and redirects them to the mobile or full version of your site. Scripts like this are a light weight/high performance alternative to more elaborate device detection packages like WURFL or Device Atlas. For blogs and news sites that have a mostly-text, “one size fits all” mobile site this script is all you need to send mobile visitors to it.
There are quite a few similar mobile device detection scripts floating around the net. Eugenia’s is by far the most complete in terms of the number of different mobile user agents it tests for. The script even recognizes text-only, legacy desktop, PDA, game console and embedded systems browsers that would choke on a typical desktop site and sends them to your mobile version. There’s a hook to optionally redirect wml-only devices to a wml version of your site and logic to make sure that search engine crawlers see your full site. It also detects those pesky transcoders and redirects them to your mobile site where you should be sending a Cache-Control No-Transform header to tell them to leave your content alone.
The script will require a little tweaking to get working on your site as the targets of the redirection are hard-coded. The README.txt file included in the download tells you everything you need to know in order to use it and has suggestions for advanced use. It’s open source so you are free to modify it to suit your needs.
Download the Mobile Detection Kit here. One word of warning. It’s fine to automatically deliver mobile formatted content to mobile browsers, but always provide users with a way to reach your full site if they want to. It’s unlikely that you mobile edition contains all the content of your desktop version. Users hate being blocked from content. Just add a “Full Version” link on the mobile site that bypasses the detection script or sets a cookie that the script can be modified to check.