Manage cookies that are used for advertising, such as ad personalization, remarketing, and ad effectiveness analysis.
2.7.1.1.7. Restrict access by User-Agent
Attention!
Directives in .htaccess will not work for files whose extensions are specified in the static files list.Directives should be placed in the .htaccess file in the directory of the site to which access should be restricted. Visitors with restricted access will receive a 403 response.
Some User-Agents are blocked by hosting by default.
Allow access to all except specified User-Agents
Example of blocking facebookexternalhit, YandexBot and Bingbot:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(facebookexternalhit|YandexBot|Bingbot).*$ [NC]
RewriteRule .* - [F,L]
Instead of facebookexternalhit, YandexBot and Bingbot, you can specify any User-Agent that needs to be blocked (you can specify them in any case, separating them with the | symbol).
Deny access to all except specified User-Agents
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !^.*(useragent1|useragent2|useragent3).*$ [NC]
RewriteRule .* - [F,L]
Instead of useragent1, useragent2 and useragent3, specify the User-Agents that should have access to the site (you can specify them in any case, separating them with the | symbol).
(1)
Comments