2.7.1.1.7. Access restriction by User-Agent
Attention!
Directives in .htaccesswill not work for files with extensions specified in list of static files.Directives must be placed in a file .htaccesslocated in the directory of the site to which you want to restrict access. Restricted visitors will receive answer 403.
Some User-Agents already blocked hosting by default.
Access is open to everyone except the specified User-Agent
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^.*(useragent1|useragent2|useragent3).*$ [NC] RewriteRule .* - [F,L]
Instead useragent1
, useragent2
and useragent3
specify the User-Agent to block (you can specify it in any case).
Access is closed for everyone except the specified User-Agent
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} !^.*(useragent1|useragent2|useragent3).*$ [NC] RewriteRule .* - [F,L]
Instead useragent1
, useragent2
and useragent3
specify the User-Agent that should have access (you can specify it in any case).