.htaccess

RewriteCond %{HTTP_USER_AGENT} «.*Имя_браузера_или_бота*.» [OR]
не забываем !!! [OR], для объединения операторов

для запрета доступа по IP адреса

Order deny,allow
Deny from 192.168.042.243


< IfModule mod_rewrite.c>  
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ".*AhrefsBot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*SemrushBot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*MJ12bot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*Riddler*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*aiHitBot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*trovitBot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*Detectify*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*BLEXBot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*dotbot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*FlipboardProxy*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*rogerBot*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*MegaIndex.ru/2.0*." [OR]
 RewriteCond %{HTTP_USER_AGENT} ".*LinkpadBot*."
 RewriteRule ".*" "-" [F]
</ IfModule>