.htaccess Condition to check the device accessed using HTTP_USER_AGENT

Below code is the condition to check the web site accessing device is from mobile using "HTTP_USER_AGENT" in .htaccess file. You can use this condition and create a RewriteRule for any redirection.

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]

 

Category: