Magento has this built-in already:
UPDATE:
Apologizes for missing the redirecting portion of your question, most likely you'll want to take a look at something like a lightweight php class to use in your index.php
to determine such. If you can avoid the headaches of regular expressions with .htaccess, its always best.
Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment. http://mobiledetect.net
- https://github.com/serbanghita/Mobile-Detect
- http://www.magentocommerce.com/magento-connect/catalog/product/view/id/16835/