Apache Mobile Filter is the easiest way to detect mobile devices.
AMF is a suite of tools that allow access to a Device Repository (such as WURFL, DetectRight, 51Degrees or others) directly from Apache: now you can detect devices no matter what language your website uses.

Apache Mobile Filter site:

http://www.apachemobilefilter.org

Documentation site:

http://wiki.apachemobilefilter.org

Demo site:

http://litedetection.apachemobilefilter.org

http://fiftyone.apachemobilefilter.org

http://w.apachemobilefilter.org

Support:

http://groups.google.com/group/amf-device-detection?hl=en

AVAILABILITY

The latest version of Apache Mobile Filter is available from the
CPAN <http://search.cpan.org/>

or

http://www.sourceforge.net/projects/mobilefilter/files/latest/download

COPYRIGHT

Copyright 2009-2010-2011-2012-2013 Idel Fuschini <idel.fuschini@gmail.com>

This package is free software and is provided "as is" without express
or implied warranty.  You can redistribute it and/or modify it under 
the same terms as Perl itself.