I think .htaccess would be the fastest. you might put something like this in your htaccess file.
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://m.mydomain.com/$1 [L,R=302]