An Apache rewrite rule can reject requests that use a specified bot user-agent string. This guide explains how to add that rule to a website’s .htaccess file through cPanel.
Edit the correct file
-
Back up the existing
.htaccessfile. -
Open Files > File Manager and navigate to the website’s document root. Enable Show Hidden Files if needed.
-
Edit
.htaccess, preserving existing application rules. -
Place the following before broader application rewrite rules, replacing
ExampleBotwith the intended user-agent pattern:RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ExampleBot [NC] RewriteRule ^ - [F,L]
For several patterns, use a single condition such as:
RewriteCond %{HTTP_USER_AGENT} (Baiduspider|HTTrack|Yandex) [NC]Use that condition with the same RewriteEngine and RewriteRule, rather than adding it as an unrelated rule.
Test the result
Save and check normal requests and a request with a matching user agent. The latter should receive HTTP 403. Restore the backup if the site fails or legitimate clients are blocked.
Apache must permit rewrite rules here. User-agent strings can be forged; these rules do not guarantee removal from search results or replace other security controls.

