Documentation
ScraperBlock
Htaccess Blocking

Htaccess Blocking

When Enable Htaccess Blocking is on, ScraperBlock writes mod_rewrite rules to your .htaccess file that reject matched user-agents with a 403 before PHP (and WordPress) loads.

Example Rules

# BEGIN ScraperBlock
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} GPTBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ChatGPT\-User [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Google\-Extended [NC,OR]
...
RewriteCond %{HTTP_USER_AGENT} My\sCustom\sBot [NC]
RewriteRule .* - [F,L]
</IfModule>
# END ScraperBlock
⚠️

Htaccess blocking only works on Apache servers. It has no effect on Nginx, LiteSpeed (unless .htaccess compatibility is enabled), or other server types. Do not enable this setting on non-Apache servers.

There is one condition per blocked bot (built-in list plus your Custom User-agents), joined with [OR] so a request matching any of them is rejected. Spaces in custom user agents are written as \s.

Before ScraperBlock 1.0.4, the generated conditions were missing [OR], so .htaccess blocking didn't block anything (runtime blocking still did). Updating to 1.0.4 rewrites your rules automatically the first time an admin page loads.

Activation & Deactivation Behaviour

  • On plugin activation (if htaccess blocking is enabled in settings): rules are written automatically.
  • On plugin deactivation: all ScraperBlock htaccess rules are removed.
  • On settings save (toggling htaccess blocking): rules are synced automatically.

When Allow AI Search Bots is on, AI search bots (OAI-SearchBot, ChatGPT-User, PerplexityBot, Perplexity-User, MistralAI-User) are left out of the rules. Save your settings after changing it so the .htaccess rules are rewritten.