Search code examples
.htaccessuser-agent

.htaccess allow only user-agents that contain a specific word


I would like to know if there is a way to block all user-agents except the one that contains the word "chrome" using .htaccess

I used something like this, but this works unfortunately only if the exact name is given..

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} !Lynx/2\.8\.8dev\.12 [NC]

RewriteRule ^ - [F,L]

Solution

  • You can just use:

    RewriteEngine On
    
    RewriteCond %{HTTP_USER_AGENT} !chrome [NC]
    RewriteRule ^ - [F]