Back to Knowledge Base
Knowledge Base Backups & Security How to Block Bad Bots and IP Addresses

How to Block Bad Bots and IP Addresses

Backups & Security 30/11/2026

Block a Specific IP via .htaccess

Order allow,deny
Deny from 198.51.100.0
Allow from all

Block a range:

Deny from 198.51.100.0/24

Block by User Agent (Bot Blocker)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} "AhrefsBot|SemrushBot|MJ12bot|DotBot" [NC]
    RewriteRule .* - [F,L]
</IfModule>

Block Access to wp-admin Except Your IP

<Files wp-login.php>
    Order deny,allow
    Deny from all
    Allow from 203.0.113.10
</Files>

Using Cloudflare to Block IPs (Recommended)

If you use Cloudflare:

  1. Go to Security → WAF → Custom Rules.
  2. Create a rule: IP Source Address equals [bad IP] → Action: Block.

Cloudflare blocks at the edge, before requests reach your server.

Monitoring for Brute Force Attacks

Check your access logs via SSH:

tail -f ~/logs/yourdomain.com/access.log | grep "POST /wp-login"

Install Wordfence (WordPress) or Fail2Ban (contact support) to automatically block repeated failed logins.

Was this article helpful?