How to Block AI Crawlers: robots.txt, Cloudflare WAF, NGINX, and Server Rules

Blocking AI crawlers prevents large language model (LLM) companies from scraping your website content for AI training or live answer generation. You declare opt-out rules in robots.txt for compliant bots (GPTBot, ClaudeBot, Google-Extended) and enforce hard HTTP 403 blocks at your firewall or web server. The best blocking strategy separates training scrapers from AI search bots.

Which AI Crawlers to Block: Training Bots vs AI Search Bots vs Fetchers

An AI crawler is an automated bot that fetches web pages for an AI company across 3 separate jobs: LLM model training (GPTBot, ClaudeBot, CCBot), AI search citation indexing (OAI-SearchBot, PerplexityBot), and user-triggered live page fetching (ChatGPT-User), while Google-Extended and Applebot-Extended act as training opt-out control tokens rather than standalone crawlers. Blocking every AI bot blindly removes your website from ChatGPT Search and Perplexity citations alongside training datasets. The table below classifies 12 primary AI user-agent tokens by operator, job type, and blocking effect.

User-Agent Token Operator Bot Category / Job Effect of Blocking (Disallow: /)
GPTBot OpenAI Training Opts out of OpenAI training.
OAI-SearchBot OpenAI AI Search Removes site from ChatGPT Search.
ChatGPT-User OpenAI Live Fetcher Blocks live queries in ChatGPT.
ClaudeBot Anthropic Training Opts out of Anthropic training.
PerplexityBot Perplexity AI AI Search Removes site from Perplexity search.
Google-Extended Google Control Token Opts out of Gemini training.
Applebot-Extended Apple Control Token Opts out of Apple training.
Meta-ExternalAgent Meta Training & RAG Opts out of Meta Llama training.
CCBot Common Crawl Open Dataset Excludes site from Common Crawl.
Bytespider ByteDance Training Scraper Blocks ByteDance scraping.
Amazonbot Amazon Search & AI Blocks Alexa and AWS indexing.
cohere-ai Cohere Training & RAG Opts out of Cohere training.

Blocking GPTBot, ClaudeBot, Google-Extended, or Applebot-Extended has zero negative impact on traditional Google Search or Bing rankings because Google Search uses Googlebot. Review operational nuances in Does Blocking AI Crawlers Hurt SEO? and inspect all cataloged bots in The Complete List of AI Crawlers and Bots.

Method 1: How to Block AI Crawlers in robots.txt (3 Copy-Paste Templates)

To block compliant AI crawlers using your robots.txt file, paste 1 of 3 rule templates at the root of your domain (https://example.com/robots.txt) depending on whether you want to block only AI model training or block all AI bots completely.

Operators select from 3 deployment options:

  1. Template A: Block AI Training Scrapers Only, Allow AI Search Citations: This rule blocks GPTBot, ClaudeBot, Google-Extended, Applebot-Extended, CCBot, Meta-ExternalAgent, and Bytespider from model training, while allowing OAI-SearchBot and PerplexityBot to preserve search citations in AI answers:
    User-agent: GPTBot
    Disallow: /
    
    User-agent: ClaudeBot
    Disallow: /
    
    User-agent: Google-Extended
    Disallow: /
    
    User-agent: Applebot-Extended
    Disallow: /
    
    User-agent: CCBot
    Disallow: /
    
    User-agent: Meta-ExternalAgent
    Disallow: /
    
    User-agent: Bytespider
    Disallow: /
    
    User-agent: cohere-ai
    User-agent: Diffbot
    Disallow: /
    
    User-agent: OAI-SearchBot
    Allow: /
    
    User-agent: PerplexityBot
    Allow: /
  2. Template B: Total AI Lockdown: This rule applies a blanket disallow across all AI agents, including OAI-SearchBot, ChatGPT-User, PerplexityBot, Amazonbot, and Diffbot while keeping search engines like Googlebot authorized:
    User-agent: GPTBot
    User-agent: OAI-SearchBot
    User-agent: ChatGPT-User
    User-agent: ClaudeBot
    User-agent: PerplexityBot
    User-agent: Google-Extended
    User-agent: Applebot-Extended
    User-agent: CCBot
    User-agent: Meta-ExternalAgent
    User-agent: Bytespider
    User-agent: Amazonbot
    User-agent: cohere-ai
    User-agent: Diffbot
    Disallow: /
  3. Template C: Block AI Crawlers From Specific Directories: Restricting access to sensitive paths protects documentation or premium sections while leaving marketing pages crawlable:
    User-agent: GPTBot
    User-agent: ClaudeBot
    Disallow: /blog/
    Disallow: /docs/
    Disallow: /pricing/

The robots exclusion standard (RFC 9309) operates as a voluntary instruction rather than an impenetrable security barrier. Reputable AI companies respect robots.txt rules, whereas unauthorized scrapers and spoofed agents ignore voluntary directives unless firewalls enforce hard rejections. Administrators explore standard directives in robots.txt: The Complete Guide With Examples and configure permissive policies in How to Allow AI Crawlers.

Method 2: How to Block AI Bots at the Server Level (NGINX and Apache .htaccess HTTP 403)

To physically block AI crawlers that ignore robots.txt before they download your HTML or consume server CPU, configure an HTTP 403 Forbidden user-agent rejection rule inside NGINX (nginx.conf) or Apache (.htaccess).

Administrators enforce origin-level blocking through 2 configurations:

  1. Block AI Crawlers in NGINX: The NGINX map directive matches user-agent strings via hash tables. Add this block to the http {} section of your configuration, then reject matching traffic inside your server {} block:
    # 1. Place inside the http {} block in nginx.conf:
    map $http_user_agent $block_ai_bots {
        default 0;
        "~*(GPTBot|ClaudeBot|CCBot|Bytespider|Meta-ExternalAgent|cohere-ai)" 1;
    }
    
    # 2. Place inside your site's server {} block:
    if ($block_ai_bots) {
        return 403;
    }
    Validate syntax and reload NGINX with sudo nginx -t && sudo systemctl reload nginx.
  2. Block AI Crawlers in Apache: Apache evaluates requests via the mod_rewrite module. Place these rewrite conditions at the head of your root .htaccess file to return immediate 403 Forbidden headers:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_USER_AGENT} (GPTBot|ClaudeBot|CCBot|Bytespider|Meta-ExternalAgent|cohere-ai) [NC]
        RewriteRule .* - [F,L]
    </IfModule>

Policy tokens like Google-Extended and Applebot-Extended function as robots.txt directives rather than distinct HTTP User-Agent strings. Google crawls content using Googlebot while honoring Google-Extended in robots.txt, meaning origin firewall rules require maintaining robots.txt controls alongside user-agent blocks.

Method 3: How to Block AI Scrapers in Cloudflare WAF and by IP/ASN

Blocking AI crawlers at the CDN edge using Cloudflare AI Crawl Control, custom WAF expressions, and verified IP CIDR ranges stops scraper traffic before it reaches origin servers or consumes bandwidth.

Edge protection deploys across 3 security layers:

  1. Enable Cloudflare AI Crawl Control: Navigate in Cloudflare to Security → Bots → AI Crawl Control. Toggle automated blocking for scrapers operated by OpenAI, Anthropic, ByteDance, and Common Crawl. Enabling AI Labyrinth routes scrapers that violate robots.txt into synthetic loops that exhaust crawler budgets.
  2. Deploy a Custom Cloudflare WAF Rule: Create a rule under Security → WAF → Custom rules with action Block using this compound expression:
    (http.user_agent contains "GPTBot") or (http.user_agent contains "ClaudeBot") or (http.user_agent contains "CCBot") or (http.user_agent contains "Bytespider") or (http.user_agent contains "Meta-ExternalAgent")
  3. Block Stealth Scrapers by CIDR IP Ranges and Verify Reverse DNS: Scrapers that forge desktop user-agents are isolated by IP ranges. Operators publish JSON feeds of active IP blocks. Administrators audit scraper requests using the AI Crawler Log Analyzer and confirm authenticity through forward-confirmed reverse DNS (FCrDNS) via the Reverse IP Lookup tool.

Offloading bot filtering to edge firewalls stops unwanted automated requests before they consume origin compute resources or hosting bandwidth.

Method 4: Page-Level X-Robots-Tag Headers and HTML Meta Tags (Plus 5-Method Comparison Table)

For granular page-by-page or PDF/image control, administrators add X-Robots-Tag: noai, noimageai HTTP response headers or HTML <meta> tags, though support across AI vendors varies compared to robots.txt and WAF blocks. The table below compares 5 AI crawler blocking methods by enforcement strength, granularity, and vendor support.

HTML documents restrict AI training via page-level meta directives:

<!-- Inside HTML <head> on specific pages: -->
<meta name="robots" content="noai, noimageai">

Non-HTML assets like PDF downloads and images enforce metadata protection through HTTP response headers emitted by NGINX:

# Inside NGINX location block for downloadable assets:
add_header X-Robots-Tag "noai, noimageai" always;
Blocking Method Enforcement Type Stops Non-Compliant Scrapers? Granularity Best Use Case
1. /robots.txt (Disallow: /) Voluntary Policy (RFC 9309) No (Reputable bots only) Domain or path Baseline for Google-Extended, Applebot-Extended, and GPTBot.
2. Cloudflare WAF / AI Crawl Control Hard Edge Block (HTTP 403) Yes (Blocks at CDN edge) Bot, path, ASN, IP Stopping bandwidth drain and edge scrapers.
3. NGINX / Apache .htaccess (403) Hard Origin Block (HTTP 403) Yes (Blocks matching User-Agents) Server or host VPS or servers without a CDN WAF.
4. Operator CIDR IP / ASN Firewall Network Layer Block Yes (Stops bots spoofing Chrome) IP subnet (/24, /48) Blocking known AI IP pools at iptables or security groups.
5. X-Robots-Tag / meta name="robots" Voluntary Page Directive No (Not honored by all bots) Page, PDF, image Supplementary signal on PDFs and images.

A two-layer defense architecture establishes the most reliable protection. Publishing explicit directives inside robots.txt ensures compliant bots respect your intellectual property, while edge firewall rules intercept bad-faith scrapers like Bytespider that disregard voluntary standards.

How to Test and Verify That AI Crawlers Are Blocked on Your Site (3 Steps)

Verify your blocking rules across 3 live diagnostic tests after deploying robots.txt directives and server or WAF blocks.

Engineers verify crawler permissions through 3 diagnostic phases:

  1. Audit Live Permissions Across Major AI User-Agents: Enter your domain into the AI Crawler Checker to generate a status matrix covering GPTBot, OAI-SearchBot, ClaudeBot, PerplexityBot, Google-Extended, Applebot-Extended, CCBot, and Bytespider.
  2. Validate robots.txt Syntax and Parser Formatting: Test your live file against syntax errors, wildcard conflicts, or missing end-of-line delimiters using the robots.txt Checker and Validator to prevent accidental disallow leaks.
  3. Simulate Crawler Requests Directly From the Terminal: Send simulated requests with explicit user-agents using curl -I -A to confirm that server or WAF firewalls return HTTP/2 403 Forbidden for blocked scrapers while standard browser user-agents receive HTTP/2 200 OK:
    # Test GPTBot receives HTTP 403:
    curl -I -A "Mozilla/5.0 (compatible; GPTBot/1.0; +https://openai.com/gptbot)" https://example.com
    
    # Test Googlebot receives HTTP 200:
    curl -I -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com

Establishing bot management forms an essential part of modern AI crawler access control. Mastering how to block AI crawlers through balanced robots.txt Disallow rules, selective allowances for GPTBot, ClaudeBot, and Google-Extended, and enforceable Cloudflare WAF and NGINX 403 blocks maintains control over content distribution while keeping training scrapers separated from AI search bots.

Frequently Asked Questions

Does blocking AI crawlers hurt my Google Search SEO rankings? +

No, blocking AI training crawlers (GPTBot, ClaudeBot, CCBot, and Google-Extended) has zero impact on your traditional Google Search rankings. Google Search relies on Googlebot, which operates independently from the Google-Extended training token.

Do all AI bots respect robots.txt Disallow rules? +

No, robots.txt is a voluntary instruction. Reputable operators like OpenAI, Anthropic, Google, and Apple honor robots.txt for their training crawlers, whereas aggressive scrapers and spoofed bots ignore it unless you block their User-Agent and IP ranges with a Cloudflare WAF or NGINX HTTP 403 rule.

How do I block AI from training on my content while still appearing in ChatGPT Search and Perplexity? +

In practice, we recommend a split robots.txt policy: set Disallow: / for training crawlers (GPTBot, ClaudeBot, Google-Extended, Applebot-Extended, CCBot, Meta-ExternalAgent) while setting Allow: / for search indexers (OAI-SearchBot and PerplexityBot). This keeps your brand cited with clickable links in AI answers while opting out of model training.

Why are AI bots still hitting my server after I blocked them in robots.txt? +

Two common causes explain continuing bot hits: first, CDN caching serving an old copy of your robots.txt file (purge your CDN cache after editing robots.txt), and second, non-compliant scrapers or user-triggered fetchers that ignore robots.txt and require a hard WAF or NGINX 403 block.

Last verified: 2026-11-25