.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.