Directives must be placed in a file .htaccess, located 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.
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^.*(useragent1|useragent2|useragent3).*$ [NC] RewriteRule .* - [F,L]
Instead useragent1
, useragent2
and useragent3
specify the User-Agent you want to block (you can specify it in any case).
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).