htaccess config to block depending on browser agent
In one case i wish to block all Internet Explorer versions from my site using htaccess. I have read several guides but still can not get it to work. what is the most understanding way of doing it. If somebody can show an example and explain it for better usage. In the other case i wish to ONLY allow Chrome latest version and Firefox latest version to see the website.
Solution 1:
Something along these lines:
RewriteCond %{HTTP_USER_AGENT} ^.*Chrome/10.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Firefox/4.*$
RewriteRule .* - [L]
RewriteRule .* http://mydomain.com/browsererror.html [R,L]
This will check for a User Agent containing either Chrome/10
or Firefox/4
- you can get more specific as needed. If it matches, it'll skip the final rule. If they don't have the needed browser, the final rule will hit, sending the user on a redirect to an error page of your choice.