Using htaccess to redirect to mobile version unless user wants to “force desktop version”
snippet in htaccess

Using htaccess to redirect to mobile version unless user wants to “force desktop version”

user9482

RewriteEngine On
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://www.example.com/mobile [L,R=302]