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:
The latest version of Apache Mobile Filter is available from the
Copyright 2009-2016 Idel Fuschini <firstname.lastname@example.org>
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.