Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 4 min read

How to Block AI Scrapers (GPTBot, ClaudeBot) Without Killing Your Google SEO: An RFC 9309 Deep Dive

Last Tuesday, an engineering team at a mid-tier SaaS company made a single edit to their root robots.txt file. They wanted to prevent OpenAI and Anthropic from scraping their developer documentation and API references

How to Block AI Scrapers (GPTBot, ClaudeBot) Without Killing Your Google SEO: An RFC 9309 Deep Dive

Last Tuesday, an engineering team at a mid-tier SaaS company made a single edit to their root robots.txt file.

They wanted to prevent OpenAI and Anthropic from scraping their developer documentation and API references for model training. So they copied a popular snippet from a blog post:

User-agent: *
Disallow: /api/
Disallow: /docs/

Within 72 hours, their organic Google search impressions dropped by 64%. Their interactive API explorer and public guides fell completely off the SERPs.

The reason? They treated all web crawlers as a monolith and completely ignored IETF RFC 9309 directive precedence.

Over the last 18 months, the web has bifurcated into two fundamentally different types of bots:

  1. Search & Retrieval Crawlers (Googlebot, Bingbot, Applebot): They crawl your content to index it, drive referral traffic, and display snippets in search results.
  2. AI Model Training Scrapers (GPTBot, ClaudeBot, CCBot, Bytespider, Meta-ExternalAgent): They harvest bulk text to pre-train proprietary LLMs with zero referral traffic back to your site.

If you don't configure your robots directives with mathematical precision, you will either give away your content for free or accidentally nuke your search ranking.

Here is the exact technical mechanics of IETF RFC 9309, the fatal mistakes developers make when writing rules, and how to configure a bulletproof setup.

1. Visualizing Directive Precedence: How RFC 9309 Actually Evaluates Rules

Most developers believe robots.txt reads top-to-bottom like an imperative script. It does not.

Under the standardized IETF RFC 9309 (Robots Exclusion Protocol), parsers evaluate directives using Longest Match Precedence.

RFC 9309 Directive Precedence Matrix: Resolving Allow and Disallow Conflicts for AI Scrapers vs Search Engine Crawlers

The Golden Rule of RFC 9309 Β§2.2.2:

The crawler MUST determine the most specific path match. The directive with the longest character pattern length takes absolute precedence, regardless of whether it is an Allow or Disallow.

Look at this common configuration:

User-agent: Googlebot
Disallow: /private/
Allow: /private/overview

When Googlebot checks access to /private/overview:

  • Disallow: /private/ $\rightarrow$ length = 9 characters
  • Allow: /private/overview $\rightarrow$ length = 18 characters

Because 18 > 9, the Allow rule wins. Googlebot indexes the page.

What Happens When Pattern Lengths Are Identical?

What if you have conflicting rules with the exact same length?

User-agent: Googlebot
Disallow: /blog$
Allow: /blog$

RFC 9309 Β§2.2.2 explicitly dictates the tie-break: Allow always wins over Disallow when pattern lengths are equal.

2. The 9 AI Crawlers You Need to Separate

Do not block AI bots under User-agent: *. Modern AI companies run dedicated crawler tokens with separate purposes:

Bot User-Agent Operator Primary Mission Should You Block?
GPTBot OpenAI Foundation model training Block (Unless you license data)
ChatGPT-User OpenAI Real-time browsing inside ChatGPT Keep Allowed (Sends user referral traffic)
ClaudeBot Anthropic Claude model training & scraping Block
PerplexityBot Perplexity AI Search indexing & citations Keep Allowed (Provides citation traffic)
CCBot Common Crawl Massive open web scraping dataset Block (Scraped by thousands of LLMs)
Google-Extended Google Gemini & Vertex AI training Block (Does NOT affect Google Search!)
Bytespider ByteDance / TikTok AI scraping & aggressive crawling Block (Extremely heavy request volume)
Applebot-Extended Apple Apple Intelligence training Block
Meta-ExternalAgent Meta Llama training & indexing Block

⚠️ Key Gotcha: Notice the difference between Googlebot and Google-Extended. Blocking Google-Extended prevents Google from training Gemini on your articles, but it has zero negative impact on your Google Search rankings.

3. The Production-Ready robots.txt Architecture

Here is a tested, production-grade template that stops aggressive training scrapers while keeping Googlebot, Bingbot, and real-time AI citation engines running at full speed:

# ==============================================================================
# 1. ALLOW SEARCH ENGINES & CITATION BOTS (High Referral Value)
# ==============================================================================
User-agent: Googlebot
User-agent: Bingbot
User-agent: Applebot
User-agent: ChatGPT-User
User-agent: PerplexityBot
Allow: /
Disallow: /admin/
Disallow: /api/internal/
Disallow: /staging/

# ==============================================================================
# 2. CONTAIN DEDICATED AI TRAINING SCRAPERS (Zero Referral Value)
# ==============================================================================
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: CCBot
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: Bytespider
User-agent: Meta-ExternalAgent
User-agent: Amazonbot
Disallow: /

# ==============================================================================
# 3. GLOBAL FALLBACK FOR OTHER LEGITIMATE WEBSITES
# ==============================================================================
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /tmp/
Disallow: /*?*preview=true

# ==============================================================================
# 4. SITEMAPS
# ==============================================================================
Sitemap: https://yourdomain.com/sitemap-index.xml

4. How to Test Your Directives Before Pushing to Production

Never push changes to robots.txt without verifying how different User-Agents parse your specific URLs.

You can verify directives locally in Python using the standard library's urllib.robotparser:

import urllib.robotparser

rp = urllib.robotparser.RobotFileParser()
rp.parse("""
User-agent: Googlebot
Disallow: /reports/
Allow: /reports/public

User-agent: GPTBot
Disallow: /
""".splitlines())

# Test Googlebot access
print("Googlebot /reports/public:", rp.can_fetch("Googlebot", "https://example.com/reports/public")) # True
print("Googlebot /reports/private:", rp.can_fetch("Googlebot", "https://example.com/reports/private")) # False

# Test GPTBot access
print("GPTBot /reports/public:", rp.can_fetch("GPTBot", "https://example.com/reports/public")) # False

If you prefer an instant interactive UI without writing scripts, we built a free, 100% in-browser RFC 9309 Robots.txt Tester & AI Crawler Validator. It runs entirely in your browser using Web Workers (zero server uploads) with 1-click test chips for all 9 AI bots and visual conflict detection.

5. Summary Checklist Before You Deploy

  1. Verify user-agent specificity: Specific tokens (User-agent: GPTBot) override general tokens (User-agent: *).
  2. Double check character lengths: Remember that a longer Allow string will override a shorter Disallow rule.
  3. Do not block ChatGPT-User or PerplexityBot if you rely on generative search engines to send you traffic.
  4. Use clean trailing wildcards (*) and line anchors ($) deliberately. /docs matches /docs-private/, whereas /docs/ only matches subpaths.

Take 10 minutes today to audit your root robots.txt. The web crawler landscape has changed forever, and outdated rules are either leaking your content or quietly killing your traffic.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.