Crawl Access & Directives • 13 min read

How to Block Bad Bots with Robots.txt (Without Blocking Googlebot)

Learn how to block bad bots with robots.txt without blocking Googlebot. Includes a bad-bot list, copy-paste rules, and how to test them safely.

By SEO Free Editorial Team
Published: November 29, 2026
Block bad bots with robots.txt guide — block scrapers and AI crawlers without blocking Googlebot, on SEO Free

Every website gets visited by bots. Some are welcome: Googlebot indexes your pages, Bingbot does the same, and a handful of legitimate crawlers keep search results fresh. But a large share of bot traffic is not helpful at all. Scrapers copy your content, aggressive SEO crawlers hammer your server thousands of times a day, AI training bots harvest your text, and spam bots probe for weaknesses. Left alone, these bad bots eat your crawl budget, slow your site for real visitors, and inflate your server bill.

The simplest defence is already built into every website: the robots.txt file. A few well-written rules can tell unwanted bots to stay away while leaving Googlebot and other good crawlers completely free to do their work. This guide explains which bots are worth blocking, how to write rules that actually work, and how to test them before they go live — using SEO Free's free Bulk Robots.txt Tester.

What Counts as a Bad Bot?

A "bad bot" is any automated visitor that takes value from your site without giving anything back. They fall into a few recognisable groups:

  • Content scrapers — bots that copy your articles, product listings, or prices and republish them elsewhere, sometimes outranking you with your own words.
  • Aggressive SEO crawlers — tools such as AhrefsBot, SemrushBot, and MJ12bot that crawl your site to build link indexes. They are not malicious, but they can request thousands of pages a day on a small site.
  • AI training crawlers — bots such as GPTBot, CCBot, and ClaudeBot that collect text to train large language models. Blocking them is a legitimate choice if you do not want your content used that way.
  • Spam and probe bots — bots that hunt for login pages, comment forms, and known vulnerabilities, or that submit fake form entries.
  • Bandwidth hogs — download managers and image harvesters that pull large files repeatedly.

Not every bot in these groups deserves a block. An SEO crawler that visits a few times a week is harmless, and some AI crawlers power features — such as search citations — that may actually send you traffic. Block selectively, starting with the bots that cost you the most and give you the least.

How Robots.txt Blocking Actually Works

A robots.txt file is a plain-text set of instructions at the root of your site, for example https://seofree.online/robots.txt. Each rule names a bot by its user-agent string and then says which paths it may or may not fetch:

  • User-agent: the bot the rule applies to. An asterisk (*) means "all bots".
  • Disallow: a path the bot must not request. Disallow: / blocks the whole site; Disallow: /wp-admin/ blocks one folder.
  • Allow: an exception inside a disallowed area, for example allowing one file inside a blocked folder.

Three facts matter before you write a single rule. First, robots.txt is a request, not a lock: well-behaved bots obey it, but a malicious scraper can simply ignore it. Second, a Disallow rule does not remove a URL from Google's index — it only stops Googlebot fetching it, which can leave the URL listed without a description. Third, robots.txt cannot protect private pages: anyone who knows a URL can still open it directly, so never rely on robots.txt for security. If you need a page truly private, use a password or login, not a Disallow rule.

Step 1: Find Out Which Bots Are Hitting Your Site

Do not block bots by guesswork. Open your server access log or your hosting control panel's raw access logs and look at the user-agent column for the last seven days. Sort by request count. You will usually see Googlebot and Bingbot at the top, followed by a long tail of others.

Flag a bot for blocking when it meets two or more of these tests: it requests hundreds of pages a day, it fetches pages that have no value to it (such as search-result pages or admin URLs), it ignores your crawl-delay or rate limits, or its user-agent belongs to a scraper or data-harvesting service. Note the exact user-agent string — robots.txt matching depends on it — and note which paths it hits most, so you can block narrowly instead of blocking the whole site.

If your host does not give you raw logs, Google Search Console's crawl-stats report shows Googlebot's activity, and many analytics tools let you filter traffic by user-agent. A single day of log data is usually enough to name your worst offenders.

Step 2: Build a Shortlist of Bots to Block

Start with the bots below. They are the most commonly blocked names on small and medium sites, and each one is widely documented. Only block the ones that actually appear in your logs — a rule for a bot that never visits your site is harmless, but a long blocklist makes the file harder to maintain.

  • AhrefsBot — the Ahrefs link-index crawler. Heavy on small sites; safe to block if you do not use Ahrefs.
  • SemrushBot — the Semrush crawler. Same reasoning as AhrefsBot.
  • MJ12bot — the Majestic crawler. Often one of the most aggressive crawlers on a small site.
  • DotBot — the Moz crawler. Moderate volume, but easy to block if you do not use Moz.
  • GPTBot — OpenAI's training crawler. Block it if you do not want your content used to train models.
  • CCBot — Common Crawl's crawler. Its data feeds many AI training sets.
  • ClaudeBot — Anthropic's crawler. Block it if you do not want your content in Claude's training data.
  • Bytespider — ByteDance's crawler. Notorious for very high request volumes.
  • PetalBot — Huawei's search crawler. Low value for most sites outside China.
  • YandexBot — Yandex's crawler. Block it if you get no traffic from Yandex.

Never block Googlebot, bingbot, or Googlebot-Image unless you have a specific, deliberate reason — blocking them removes your pages from search results. Also leave Applebot alone if you care about Apple News or Siri suggestions, and leave the crawlers of any service you actually use, such as a monitoring tool or an uptime checker.

Step 3: Write the Block Rules

Open your robots.txt file and add one group per bot. A group that blocks a bot from the whole site looks like this:

User-agent: AhrefsBot

Disallow: /

To block several bots, repeat the group for each one. You can also put several user-agents in one group, but separate groups are easier to read and edit later:

User-agent: AhrefsBot

Disallow: /

User-agent: SemrushBot

Disallow: /

User-agent: MJ12bot

Disallow: /

User-agent: GPTBot

Disallow: /

User-agent: CCBot

Disallow: /

User-agent: ClaudeBot

Disallow: /

If you only want to block a bot from part of your site — for example, keeping an SEO crawler out of your image folders while letting it read your articles — narrow the Disallow path:

User-agent: SemrushBot

Disallow: /images/

Disallow: /downloads/

Keep your existing rules for Googlebot and other good crawlers untouched, and keep the general User-agent: * group — if you have one — at the bottom of the file. Bots read the most specific matching group, so a bot named in its own group follows that group and ignores the wildcard group. If you do not have a robots.txt file yet, build one with a robots.txt generator and add the block groups to it.

Step 4: Test the Rules Before Publishing

A typo in robots.txt can block Googlebot by accident, so never publish untested rules. Test them with the free Bulk Robots.txt Tester on SEO Free, which checks many URLs against your robots.txt at once:

  1. Open the Bulk Robots.txt Tester.
  2. Choose the paste mode and paste your edited robots.txt into the rules box.
  3. Paste a list of your important URLs into the URL box — your homepage, a few articles, a product page, and one or two URLs inside any folder you blocked.
  4. Run the test and read the result for each URL: Allowed means the bot may fetch it, Blocked means the rule stops it.
  5. Check the results twice: once with the blocked bot's user-agent, and once with Googlebot's. A good ruleset shows Blocked for the bad bot and Allowed for Googlebot on the same URLs.

If a URL you meant to protect shows Allowed, your Disallow path is wrong — usually a missing trailing slash or a path that does not match the real URL. If Googlebot shows Blocked on an important page, stop: a rule is too broad, most often a Disallow: / sitting in the wrong group or a wildcard group that catches Googlebot. Fix the rule and test again until every result is exactly as intended.

Step 5: Publish and Watch the Results

Save the tested file as robots.txt at the root of your site, replacing the old one. Then confirm it is live by opening yourdomain.com/robots.txt in a browser — you should see your new block groups.

Good bots usually pick up the new file within a day. Watch your access logs over the next week: requests from the blocked user-agents should fall sharply, while Googlebot's requests stay steady. Also check your crawl budget — with fewer junk requests, Googlebot spends more of its crawl on pages that matter.

Check Google Search Console a few days after publishing. If a page you care about suddenly shows as blocked, revisit Step 4: the tester catches the mistake faster than Search Console does. Re-check the file after every site change, because a redesign or a migration can change URL paths and silently break your rules.

Tips for Keeping Bad Bots Out

  • Block narrowly first. Start with the two or three worst bots from your logs, measure the effect for a week, then add more. A short, accurate blocklist beats a long, copied one.
  • Use exact user-agent names. Robots.txt matches the start of the user-agent string, so "AhrefsBot" matches "AhrefsBot/7.0" but "ahrefs" in lowercase will not match. Copy the name exactly as it appears in your logs.
  • Do not copy giant blocklists blindly. Lists circulating online include bots you may actually want — uptime monitors, feed readers, and the crawlers of tools you pay for. Every name on your list should be a bot you have seen in your own logs.
  • Pair robots.txt with rate limiting. Robots.txt only works on polite bots. For scrapers that ignore it, ask your host about rate limiting, or use a firewall rule that blocks the offending IP addresses.
  • Keep your sitemap honest. Do not list blocked URLs in your sitemap — Google treats a sitemap entry it cannot fetch as an error. If you block a section, remove it from the sitemap too.
  • Revisit the list every few months. Bots change names, new AI crawlers appear, and a bot you blocked last year may now power a feature you want. Our guide to AI crawler rules in robots.txt covers the fast-moving AI side in detail.

Common Problems

The blocked bot keeps coming

Some scrapers ignore robots.txt entirely. If the requests continue at the same rate after a week, the bot is not reading your file. Block it at the server or firewall level instead — by user-agent or by IP — and report the abuse to its operator if it publishes a contact address.

Googlebot is blocked by mistake

This usually means a Disallow: / ended up in the wildcard group or in a group whose user-agent line was mistyped, so Googlebot fell through to the wrong rules. Open the file, check every group header, and re-test with the Bulk Robots.txt Tester using Googlebot as the user-agent before re-publishing.

Blocked pages still appear in search results

Robots.txt stops crawling, not indexing. If Google already indexed a page before you blocked it, the listing can linger with no description. To remove it properly, allow crawling and add a noindex tag to the page instead — then Google can fetch the page, see the tag, and drop it. Our guide on robots.txt vs noindex explains when to use each one.

The file returns a 404 or a server error

A missing robots.txt file means every bot is allowed everywhere — the safe default, but your blocks do nothing. A 500 error is worse: Google treats it as "do not crawl anything" and may stop indexing your site. Make sure the file is a plain text file named exactly robots.txt, saved at the site root, and returning HTTP 200.

Rules work in the tester but not in Search Console

Search Console caches your robots.txt for up to 24 hours, and the tester in Search Console uses the cached copy. Wait a day, then re-test. Also check for a second robots.txt served from a subdomain or a CDN — the file Google reads must be the one on your main domain.

FAQ

Does blocking a bot in robots.txt remove my pages from Google?

No — as long as you block only that bot's user-agent, Googlebot is unaffected. The danger is a mistake in the file, such as putting a broad Disallow in the wildcard group. Always test your rules with Googlebot as the user-agent before publishing.

Can robots.txt block all AI crawlers at once?

There is no single rule that covers every AI crawler, because each one uses its own user-agent name. You need one group per crawler — GPTBot, CCBot, ClaudeBot, and any others in your logs. New AI crawlers appear regularly, so review your logs and update the list every few months.

Will blocking AhrefsBot or SemrushBot hurt my SEO?

No. Those crawlers build third-party link indexes; they do not influence Google's rankings. Blocking them only stops their tools from reporting on your site. If you use Ahrefs or Semrush yourself, keep their bots allowed so your own reports stay accurate.

Is it better to block bots with robots.txt or with a firewall?

Use robots.txt for polite bots — it is standard, cheap, and easy to change. Use a firewall or server rule for bots that ignore robots.txt, because only the server can actually stop them. Most sites end up using both: robots.txt for the well-behaved majority, and firewall rules for the persistent few.

How do I know the block is actually working?

Compare your access logs before and after publishing. Requests from the blocked user-agent should drop to near zero within a few days. If they do not, the bot is ignoring your file and needs a server-level block. Also re-run the Bulk Robots.txt Tester after every edit to confirm the rules still behave as intended.

Bottom Line

Bad bots are a tax on every website: they consume crawl budget, slow your server, and copy your work. A short, tested set of robots.txt rules is the cheapest way to cut that tax. Find the worst offenders in your logs, block them by exact user-agent name, test every rule with the Bulk Robots.txt Tester — checking both the bad bot and Googlebot — and then watch your logs to confirm the traffic drops. Revisit the list every few months, because the bots change, and a robots.txt file that is never reviewed slowly stops matching reality.

Validate Your Robots.txt Directives in Bulk

Test up to 100 paths simultaneously against your live or draft rules using our RFC 9309 compliant evaluation engine.

Open Bulk Robots.txt Tester

Related Technical Guides