Blocking Bad Bots on WordPress: Read Your Access Logs First, Verify Real Googlebot, Then Block at Cloudflare, the Server or a Plugin

By Information Security Asia · Updated November 30, 2026 · 7 min read

Blocking Bad Bots on WordPress: Read Your Access Logs First, Verify Real Googlebot, Then Block at Cloudflare, the Server or a Plugin

Short answer: To block bad bots on WordPress, start with your server access logs, not a plugin. Find the IP addresses, user agents and URLs generating the most requests, then sort them into good bots (real search engines), bots you can ignore, and bad bots: scrapers, vulnerability scanners, fake crawlers and login hammering. Verify that anything calling itself Googlebot really is, using a reverse and forward DNS lookup, before blocking it. Then block at the cheapest layer you control: a CDN or firewall such as Cloudflare’s bot and WAF rules first, the web server (Nginx or Apache rules) second, and a WordPress security plugin last, because by the time PHP runs, the bot has already cost you resources. Remember robots.txt only guides polite bots; bad bots ignore it.

Why bad bots matter for WordPress

Bots make up a large share of traffic on most WordPress sites. Many are useful: search engine crawlers, uptime monitors, feed readers. Others cause real harm. Vulnerability scanners probe every known plugin path looking for something outdated. Scrapers copy your content and republish it. Aggressive crawlers can hit uncached pages hundreds of times a minute, pushing a small VPS or shared hosting account to its limits. Fake crawlers spoof the Googlebot name to slip past rules that whitelist search engines. And bots hammer wp-login.php and xmlrpc.php trying passwords.

Blocking Bad Bots on WordPress: Read Your Access Logs First, Verify Real Googlebot, Then Block at Cloudflare, the Server or a Plugin

Login attacks have their own playbook; our guide to stopping WordPress brute force attacks covers them in depth. This guide focuses on the wider bot problem.

Step 1: read your access logs

Blocking blindly risks shutting out search engines or real visitors. Look at what’s actually hitting your site. On most Linux servers, Nginx logs are in /var/log/nginx/ and Apache logs in /var/log/apache2/ or /var/log/httpd/; control panels like cPanel and aaPanel show them in their own log viewers. These commands summarize a standard combined-format log:

# Top 20 IP addresses by request count
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20

# Top 20 user agents
awk -F'"' '{print $6}' access.log | sort | uniq -c | sort -rn | head -20

# Most requested paths that returned 404
awk '$9 == 404 {print $7}' access.log | sort | uniq -c | sort -rn | head -20

Look for patterns: a single IP making thousands of requests, user agents that are empty or obviously automated, and bursts of 404s for paths like /wp-content/plugins/some-plugin/readme.txt or /.env, which indicate vulnerability scanning.

Step 2: sort bots into categories

Bot type Typical signs in logs Action
Search engine crawlers (Googlebot, Bingbot) Known user agents, IPs that verify by DNS Allow
Fake search crawlers Googlebot user agent, IP fails DNS verification Block
Vulnerability scanners Many 404s on plugin paths, .env, backup files Block or challenge
Content scrapers Rapid requests for every post, generic or fake browser user agents Rate-limit or block
AI and dataset crawlers Named crawler user agents Your choice: allow, or disallow in robots.txt and block if ignored
SEO tool crawlers Named crawler user agents, high volume Allow, slow or block based on your needs
Login and XML-RPC hammering POSTs to wp-login.php or xmlrpc.php Rate-limit, block XML-RPC if unused

Step 3: verify real Googlebot before blocking

Anyone can put “Googlebot” in a user agent string. Google documents a simple verification: do a reverse DNS lookup on the IP, check it ends in googlebot.com, google.com or googleusercontent.com, then do a forward lookup on that hostname and confirm it returns the same IP. Google also publishes the IP ranges its crawlers use. Bing offers a similar verification for Bingbot.

host 66.249.66.1
# should return a hostname ending in googlebot.com
host crawl-66-249-66-1.googlebot.com
# should return the original IP

If a “Googlebot” fails verification, it’s safe to block. Never block real Googlebot traffic broadly; it can remove your pages from search results.

Step 4: block at the edge if you can

Blocking at a CDN or reverse proxy stops bad traffic before it reaches your server at all, which saves CPU, memory and bandwidth. If your site is behind Cloudflare:

  • Bot Fight Mode (available on the free plan) challenges traffic that matches known bot patterns. Test it, because it can affect legitimate automated tools such as uptime monitors or payment webhooks.
  • WAF custom rules let you block or challenge by path, country, user agent, ASN or a combination. A common rule challenges requests to /wp-login.php and /xmlrpc.php from outside your own country if you don’t expect logins from abroad.
  • Rate limiting rules limit how many requests a single IP can make to a path in a time window.
  • Verified bot allowances let Cloudflare’s known good crawlers through even when stricter rules apply.

Other CDNs and hosting providers offer similar web application firewall features. Whatever you use, make sure your origin server only accepts traffic from the CDN, or bots will simply bypass it by hitting your server’s IP directly.

Step 5: block at the web server

Server rules are fast and don’t depend on WordPress. In Nginx, a map lets you flag user agents and return 403 for them:

Blocking Bad Bots on WordPress: Read Your Access Logs First, Verify Real Googlebot, Then Block at Cloudflare, the Server or a Plugin
map $http_user_agent $bad_bot {
    default 0;
    ~*(masscan|zgrab|nikto|sqlmap) 1;
    "" 1;
}

server {
    if ($bad_bot) { return 403; }
    location = /xmlrpc.php { deny all; }
}

On Apache with mod_rewrite, an equivalent .htaccess rule looks like this:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (masscan|zgrab|nikto|sqlmap) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* - [F,L]

Blocking empty user agents catches a lot of junk but can also catch some legitimate tools and health checks, so watch your logs after enabling it. Nginx’s limit_req module adds rate limiting for chosen paths. Only block XML-RPC if you don’t use the WordPress mobile app, Jetpack features or remote publishing tools that rely on it.

For persistent offenders, tools like fail2ban can watch logs and add temporary firewall bans for IPs that trigger too many 404s or login failures.

Step 6: plugins as the last layer

WordPress security plugins can block IPs, user agents and countries, add login rate limiting and use threat intelligence feeds. They’re convenient on shared hosting where you can’t touch the server configuration. The downside is that every blocked request still loads PHP and often WordPress itself before being rejected, so a heavy bot flood can still slow the site. Use a plugin for things only WordPress knows about, such as failed logins tied to usernames and REST API abuse; our guide to securing the WordPress REST API covers user enumeration through /wp-json/.

What about robots.txt?

robots.txt is a request, not a lock. Search engines and many named crawlers, including several AI crawlers whose operators publicly say they respect it, will follow Disallow rules. Scrapers and scanners ignore it, and some read it to find paths you’d rather they didn’t. Use robots.txt to manage polite bots, and use the firewall, server or plugin to stop the rest.

Reduce what bots can find

  • Delete unused plugins and themes rather than just deactivating them; scanners probe for known vulnerable files.
  • Block direct access to readme.txt, backup files, .git folders and .env files at the server.
  • Disable directory listing.
  • Consider moving or protecting the login page; see our guide to changing the WordPress login URL for the trade-offs.
  • Use full-page caching so legitimate and unblocked bot traffic is served cheaply.

Monitor and review

After adding rules, check your logs and any CDN analytics for a week. Make sure search engine crawl stats in Google Search Console stay normal, uptime monitors still work, and payment gateways or webhooks still reach your site. Review rules every few months, because bot behavior changes and old rules can start blocking things you need.

Frequently asked questions

Will blocking bots hurt my SEO?

Not if you allow verified search engine crawlers. Blocking fake Googlebots, scanners and scrapers doesn’t affect rankings. Blocking real Googlebot does, so always verify before blocking crawler traffic.

Is Cloudflare’s free plan enough?

For many small sites, Bot Fight Mode plus a few WAF custom rules handles most bad bot traffic. Busy or frequently targeted sites may need paid features or additional server rules.

Should I block entire countries?

Country blocks reduce noise for sites with a local audience, but attackers use servers worldwide and real visitors travel. Challenging rather than blocking, and applying it only to login and admin paths, is a safer middle ground.

Can a plugin alone stop bad bots?

It helps, but it runs after WordPress loads. For heavy bot traffic, block at the CDN or web server first and use the plugin for WordPress-specific rules.

Sources

Keep reading