If you have a mobile website running on a separate sub-domain from your root domain then you can write the following code in your .htaccess file to redirect the visitor if they are using any of the mentioned mobile devices to browse your website. Please feel free to add more to the user agent list in the code if such a need arises. You will need to substitue “xyz” in the sample code with your actual root domain.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://m.xyz.com [L,R=302]
RewriteCond %{HTTP_HOST} !^(m)\.xyz\.com [NC]