How to detect a browser with .htaccess

I want to detect users browsers with .htaccess and redirect when the user hasn’t entered the site from a mobile phone

+3
source share
1 answer

You can run here with an example.

# Rewrite requests from all user-agents except modern Internet Explorer, Firefox, Opera
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/4\.[0-9]+\ \(compatible;\ MSIE\ [0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5\.0 \(([^;]+;\ )*[^;]+\)\ Gecko/2[0-9]{3}\ Firefox/[0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Opera/[0-9.]+
RewriteRule .* X.html [L]

Adjust as needed.

+7
source

All Articles