A robots.txt file communicates crawl preferences to compliant agents; it does not enforce authorization, guarantee a bot will obey a rule or determine whether an AI system will cite a page. Configure rules under RFC 9309, test their interpretation, and independently use authentication and firewall controls for non-public material. Distinguish the actual crawler that makes an HTTP request from product-control tokens such as Google-Extended.

Search discovery, model-training preferences and user-requested fetches are separate use cases. OpenAI documents OAI-SearchBot, GPTBot and ChatGPT-User independently; their robots.txt handling is not necessarily identical. Google-Extended is a Google product-control token, not an independently identifiable HTTP crawler. The configurations below are illustrative policy options, not verified production-ready settings for every site. Check official documentation for each platform and its applicable opt-out scope.

Standards Foundation: RFC 9309 and Rule Evaluation Mechanics

The Robots Exclusion Protocol was formally standardized by the Internet Engineering Task Force (IETF) in September 2022 as RFC 9309, and is implemented by major search engines according to published specifications such as Google’s Robots.txt Specifications. To write valid rules for AI bots, technical teams must understand how compliant parsers evaluate directives.

Editorial process diagram showing a crawler request selecting a matching user-agent group, comparing path rules, choosing the most specific match, and ending in Allow or Disallow.
Robots.txt behavior depends on the matching user-agent group and the most specific applicable path rule. Image generated by AI.
RFC 9309 PARSER EVALUATION
DECISION CRITERION

RFC 9309 Parser Evaluation: Parse robots.txt Top-to-Bottom. Identify User-Agent Record Groups. Is there a group specifically matching the bot? (e.g., User-agent: OAI-SearchBot)
MATCH FOUND (YES)

Parse Specific Group

Evaluate rules strictly in that group. IGNORE all rules in User-agent: * record group. Evaluate Path Matching Directives (Allow vs. Disallow for Target URI).

  • Allow is Longer: [ACCESS GRANTED]
  • Disallow is Longer: [ACCESS BLOCKED]
NO MATCH (NO)

Parse Wildcard Group

Evaluate rules strictly in the User-agent: * record group. Which rule has the longest match?

  • Allow is Longer: [ACCESS GRANTED]
  • Disallow is Longer: [ACCESS BLOCKED]

1. The Group Isolation Rule (The Most Common Architecture Error)

Under RFC 9309, a crawler identifies the most specific matching product-token group. When multiple matching groups use the same token, their rules are combined. A specific matching group does not inherit the User-agent: * rules. Repeat needed restrictions in every specific group, and apply the longest applicable path rule within that group.

Many developers mistakenly believe that specific bot groups inherit general rules:

# CRITICAL FLAW: False assumption of inheritance
User-agent: *
Disallow: /admin/
Disallow: /private/
Disallow: /staging/

User-agent: OAI-SearchBot
Allow: /

The example above is syntactically valid but has an unintended policy result. Because OAI-SearchBot has its own group with Allow: /, the generic disallows do not carry over. A compliant crawler may therefore access the listed paths. Robots rules are not access control, so use real authorization to protect sensitive endpoints.

Whenever you define a dedicated user-agent block, you must explicitly replicate all global disallow rules inside that block.

2. The Longest-Match Precedence Rule

When multiple Allow and Disallow directives match a requested URI within the same group, the directive with the longest character count in the path pattern takes precedence.

Example:

User-agent: *
Disallow: /reports/
Allow: /reports/public-summary.html
  • For /reports/internal-data.json: Matches Disallow: /reports/ (length 9). Result: Blocked.
  • For /reports/public-summary.html: Matches both Disallow: /reports/ (length 9) and Allow: /reports/public-summary.html (length 28). Because the Allow path is longer, it wins. Result: Allowed.

If an Allow and a Disallow rule have identical path lengths (for example, Allow: /data and Disallow: /data), RFC 9309 specifies that the Allow directive takes precedence.

3. Path Matching and Trailing Slash Significance

Robots.txt path rules match the beginning of a URI path:

  • Disallow: /admin: Blocks /admin, /admin/, /administrator, and /admin-settings.php.
  • Disallow: /admin/: Blocks /admin/ and /admin/users/, but does not block /administrator.
  • Disallow: /*.pdf$: Uses the wildcard * and end-of-string anchor $ to block all URLs ending in .pdf.

Authoritative User-Agent Tokens for AI Optimization

To configure rules accurately, technical teams must use the exact, case-insensitive user-agent tokens recognized by crawler operators:

Editorial policy diagram separating search and retrieval crawlers from model-training crawlers, with an explicit-policy branch and a wildcard fallback warning.
Search discovery and model training are different publisher decisions, so high-value AI crawlers should receive explicit policies where practical. Image generated by AI.
Target Category Crawler Name Official Robots.txt Token Operational Impact of Disallow
Search Discovery Google Search Googlebot Removes site from Google Search, AI Overviews, and AI Mode
Search Discovery ChatGPT Search OAI-SearchBot Excludes site from ChatGPT Search index and source citation cards
Search Discovery Bing / Copilot Bingbot Removes site from Bing Search and Copilot web grounding
Search Discovery Perplexity AI PerplexityBot Excludes site from Perplexity search indexing and citation
Search Discovery Anthropic Search Claude-SearchBot Excludes site from Anthropic search indexing and web-search result features
Model Training OpenAI Training GPTBot Opts out of data scraping for future OpenAI foundation model pre-training
Model Training Google Generative Google-Extended Opts out of Gemini and Vertex AI training without impacting Google Search
Model Training Anthropic Training ClaudeBot Opts out of Claude model pre-training and dataset collection
Model Training Apple Foundation Applebot-Extended Opts out of Apple Intelligence training without affecting Siri/Spotlight search
User Navigation ChatGPT Direct ChatGPT-User Blocks ChatGPT from fetching specific links pasted directly into user prompts
User Navigation Claude Direct Claude-User Blocks Claude from fetching specific links pasted directly into user prompts

For detailed architectural differences between search bots and training scrapers, consult our comprehensive guide on AI Crawlers Explained and our specific comparison of OAI-SearchBot vs GPTBot.

Four Illustrative Robots.txt Policy Configurations

Adapt these example templates to your actual origin, robots.txt location, crawler inventory, access-control design and commercial policy. Verify the resulting rules with an RFC-compatible parser and test that your web server returns the expected status. An Allow directive does not force a crawler to fetch or cite a page.

Configuration 1: Maximum AI Search Visibility with Model Training Opt-Out (Recommended for Most Commercial Sites)

This sample allows requests from several named discovery agents to the listed public sections while communicating a preference against certain training-oriented uses. It does not guarantee inclusion in Google AI Overviews, ChatGPT Search, Copilot or Perplexity. Google-Extended affects specified Gemini-related training and grounding uses but does not control Google Search inclusion. See Google’s scope definition.

# ==============================================================================
# ILLUSTRATIVE EXAMPLE: SEARCH DISCOVERY WITH TRAINING OPT-OUT
# Allows real-time search discovery; blocks foundation model training scrapers.
# ==============================================================================

# Generic Crawlers: Standard Search Protection
User-agent: *
Disallow: /wp-admin/
Disallow: /private/
Disallow: /staging/
Disallow: /api/internal/
Allow: /wp-admin/admin-ajax.php

# OpenAI Search Discovery: Explicitly Allowed for ChatGPT Search
User-agent: OAI-SearchBot
Disallow: /wp-admin/
Disallow: /private/
Disallow: /staging/
Disallow: /api/internal/
Allow: /

# Perplexity Search Discovery: Explicitly Allowed
User-agent: PerplexityBot
Disallow: /wp-admin/
Disallow: /private/
Disallow: /staging/
Disallow: /api/internal/
Allow: /

# Anthropic Search Discovery Crawler
User-agent: Claude-SearchBot
Disallow: /wp-admin/
Disallow: /private/
Disallow: /staging/
Disallow: /api/internal/
Allow: /

# ==============================================================================
# Model Training Scrapers: Explicitly Blocked
# ==============================================================================

# OpenAI Foundation Model Training Scraper
User-agent: GPTBot
Disallow: /

# Anthropic Foundation Model Training Scraper
User-agent: ClaudeBot
Disallow: /

# Google-Extended is a robots.txt control for specified Gemini training/grounding uses; not an HTTP crawler
User-agent: Google-Extended
Disallow: /

# Apple Intelligence Foundation Model Training
User-agent: Applebot-Extended
Disallow: /

# XML Sitemap Declaration
Sitemap: https://example.com/wp-sitemap.xml

Configuration 2: Full Open Web Integration

Ideal for open-source repositories, developer documentation portals, and academic projects seeking maximum dissemination across both search retrieval and foundation model weights:

# ==============================================================================
# ILLUSTRATIVE EXAMPLE: FULL OPEN INTEGRATION
# Allows all search crawlers and AI training scrapers across public routes.
# ==============================================================================

User-agent: *
Disallow: /wp-admin/
Disallow: /private/
Disallow: /staging/
Allow: /wp-admin/admin-ajax.php
Allow: /

# XML Sitemap Declaration
Sitemap: https://example.com/wp-sitemap.xml

Configuration 3: Strict AI Opt-Out with Traditional Search Preservation

Designed for publishers who wish to remain fully visible in traditional search results (Google, Bing) but explicitly block all dedicated AI search discovery engines and model training scrapers:

# ==============================================================================
# ILLUSTRATIVE EXAMPLE: STRICT AI OPT-OUT
# Preserves traditional search engines; blocks AI search discovery & training.
# ==============================================================================

User-agent: *
Disallow: /wp-admin/
Disallow: /private/
Disallow: /staging/
Allow: /wp-admin/admin-ajax.php

# Block AI Search Discovery
User-agent: OAI-SearchBot
Disallow: /

User-agent: PerplexityBot
Disallow: /

User-agent: Claude-SearchBot
Disallow: /

# Block AI Model Training
User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: Applebot-Extended
Disallow: /

# Illustrative preference for user-initiated fetchers (robots.txt may not apply)
User-agent: ChatGPT-User
Disallow: /

User-agent: Claude-User
Disallow: /

# XML Sitemap Declaration
Sitemap: https://example.com/wp-sitemap.xml

Configuration 4: Granular Directory-Level Access Control

Useful for websites that maintain public editorial articles alongside proprietary datasets, member portals, or research tools:

# ==============================================================================
# ILLUSTRATIVE EXAMPLE: GRANULAR SECTION CONTROL
# Allows AI search bots to index public articles; shields data and members areas.
# ==============================================================================

User-agent: *
Disallow: /wp-admin/
Disallow: /members/
Disallow: /datasets/
Disallow: /internal/
Allow: /wp-admin/admin-ajax.php

User-agent: OAI-SearchBot
Disallow: /members/
Disallow: /datasets/
Disallow: /internal/
Allow: /articles/
Allow: /blog/
Allow: /guides/

User-agent: PerplexityBot
Disallow: /members/
Disallow: /datasets/
Disallow: /internal/
Allow: /articles/
Allow: /blog/
Allow: /guides/

User-agent: Claude-SearchBot
Disallow: /members/
Disallow: /datasets/
Disallow: /internal/
Allow: /articles/
Allow: /blog/
Allow: /guides/

User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

# XML Sitemap Declaration
Sitemap: https://example.com/wp-sitemap.xml

Critical Syntax Traps and Misconceptions

When auditing robots.txt files, technical teams frequently encounter costly implementation mistakes:

Trap 1: Relying on Robots.txt for Security or Authentication

Robots.txt is an advisory protocol, not a security firewall. As Google Search Central explicitly warns, robots.txt is not a mechanism for keeping private or sensitive material off web search engines. It does not prevent malicious actors, curl scripts, or hostile scrapers from requesting disallowed URLs. Any URL listed in a Disallow line is publicly visible to anyone reading https://example.com/robots.txt. Never list secret admin paths, private tokens, or staging URLs in robots.txt without backing them up with server-side authentication (e.g., HTTP Basic Auth, OAuth, IP whitelisting).

Trap 2: Believing Disallow Removes URLs from Search Engines

A Disallow: /page directive stops search engines from crawling the body of that page. However, as documented in Google’s Robots Documentation, if other websites link to /page, search engines can still index the URL and display it in search results based on external anchor text, though without a descriptive snippet. If your goal is complete removal from search indexes, do not use robots.txt; instead, allow the crawler to fetch the page and serve a <meta name="robots" content="noindex"> tag or an X-Robots-Tag: noindex HTTP header.

Trap 3: Expecting Retroactive Model Training Erasure

Disallowing GPTBot or ClaudeBot prevents those bots from downloading content in future crawls. It does not purge data that was crawled previously, nor does it erase neural weights already trained into existing foundation models.

Trap 4: Blank Line Formatting Errors

Correction: RFC 9309 does not require a blank line between groups. A User-agent: record after rules starts the next group, even without an empty line. Blank lines are recommended for human readability, not necessary to prevent rule merging. Consecutive User-agent: records before a rule may intentionally share a group. Read RFC 9309 section 2.2.

# VALID: the second User-agent starts a new group even without a blank line.
User-agent: Googlebot
Disallow: /staging/
User-agent: GPTBot
Disallow: /

# Blank lines remain helpful for readability.

For readability, you can insert a blank line between groups, but review group boundaries and matching behavior rather than treating whitespace as a functional access-control barrier.

Trap 5: Misplaced Inline Comments

RFC 9309 permits comments beginning with #, including comments after a rule value; compliant parsers ignore the comment. For legibility and maximum compatibility with poorly implemented custom parsers, putting comments on separate lines is a reasonable style preference, not a required fix for invalid syntax. Google’s parser specification documents inline comments.

# VALID RFC 9309 syntax, even though separate comment lines may read better:
Disallow: /private/ # do not crawl this path

Always place comments on their own dedicated lines above directives.

What About llms.txt?

A recent proposal in the developer community suggests placing a markdown file at /llms.txt to help language models discover clean site documentation. While /llms.txt offers clear utility for developer tooling and coding assistants, it is not an official search engine standard and does not replace robots.txt. For an evidence-led analysis of adoption and ranking realities, read Does llms.txt Help AI Search Rankings?.

Testing and Verification Protocol

Before deploying robots.txt changes to production, execute this validation sequence:

Lifecycle diagram showing live robots.txt fetch, user-agent match testing, CDN and firewall checks, server-log inspection, post-deploy recheck, and monitoring.
A robots.txt change should be verified against both the live file and real network behavior before it is considered complete. Image generated by AI.
ROBOTS.TXT DEPLOYMENT PIPELINE
01

Robots.txt Deployment Pipeline
→
02

1. Local Syntax Check
→
03

(Verify RFC 9309 Compliance)
→
04

2. Staging Preflight
→
05

(Confirm Exact Canonical URLs)
→
06

3. Production Deployment
→
07

(Deploy via Git / Web Server)
→
08

4. Live HTTP Header Probe
→
09

(Confirm HTTP 200 & Content-Type)
→
10

5. Search Console Testing
→
11

(Validate in Google & Bing Tools)
→
12

6. Server Access Log Monitor
→
13

(Track Response Codes to Bot Agents)

Step 1: Probe Live Response and Headers via cURL

Verify that robots.txt returns HTTP 200, serves Content-Type: text/plain, and is accessible to standard user agents:

curl.exe -sI https://example.com/robots.txt
# Expected: HTTP/1.1 200 OK
# Expected: Content-Type: text/plain; charset=UTF-8

Inspect the raw output to ensure no HTML tags or PHP errors leaked into the file:

curl.exe -s https://example.com/robots.txt | head -n 25

Step 2: Validate Against RFC 9309 Open-Source Testers

Use Google’s open-source robotstxt parser (available on GitHub as google/robotstxt) or webmaster inspection tools in Google Search Console and Bing Webmaster Tools to test specific URL paths against defined user agents.

For an RFC-aware test, use the open-source Google robots.txt parser and matcher and its included robots command, testing both allowed and blocked URLs for each specific product token. Python’s standard urllib.robotparser is useful for a rough smoke test but can disagree with RFC 9309 longest-match precedence; do not use it alone as proof that production rules are correct.

# After building Google's open-source robotstxt testing binary:
# Syntax: robots local-file user-agent full-URL
robots robots.txt OAI-SearchBot https://example.com/blog/
robots robots.txt OAI-SearchBot https://example.com/private/
robots robots.txt GPTBot https://example.com/blog/

# Expected results depend on YOUR policy; the binary reports ALLOWED/DISALLOWED.
# Tests do not prove that a request originated from an authentic crawler.

Step 3: Configure Edge CDNs and Bot Management Layers

Modern CDNs (Cloudflare, AWS CloudFront, Fastly) process incoming traffic at edge nodes before requests reach your web server’s robots.txt. Ensure your edge security policies do not conflict with your crawler directives:

  1. Cloudflare Bot Management: In the Cloudflare Dashboard under Security > Bots, review rules for "Verified Bots". Cloudflare automatically allows verified search crawlers (including Googlebot and Bingbot). For OAI-SearchBot, verify that your custom WAF rules do not subject legitimate OpenAI IP ranges to Managed Challenges.
  2. AWS WAF: If using AWS WAF Bot Control managed rule groups, create an override exception for verified search crawler User-Agents and IP CIDR blocks to avoid automated 403 blocks.
  3. LiteSpeed and Apache .htaccess Rules: Ensure that existing rewrite rules or mod_security directives do not terminate requests containing "Bot" in the User-Agent header with a 403 Forbidden status.

Step 4: Monitor Server Access Logs for Response Codes

After updating robots.txt, monitor server access logs to confirm that allowed bots (like OAI-SearchBot) are not receiving unexpected errors:

# Monitor incoming requests from AI search and training crawlers
tail -f /var/log/nginx/access.log | grep -E "(Googlebot|OAI-SearchBot|GPTBot|PerplexityBot)"

For an end-to-end diagnostic workflow covering status codes, headers, and rendering, follow our comprehensive guide on How to Audit Your Website for AI Search Crawlability.

Summary: Key Takeaways for Web Engineers

  1. RFC 9309 Group Isolation: Specific user-agent blocks (e.g., User-agent: OAI-SearchBot) do not inherit rules from User-agent: *. Replicate sensitive path restrictions across all custom groups.
  2. Decouple Search from Training: Allow OAI-SearchBot, PerplexityBot, and Claude-SearchBot for search discovery and citations; disallow GPTBot, ClaudeBot, Google-Extended, and Applebot-Extended for training opt-out.
  3. Longest Match Rules: More specific path directives always override shorter path rules regardless of order.
  4. Robots.txt is Not Security: Use server-side authentication to protect confidential files, and noindex headers to remove URLs from search indexes.
  5. Validate via Terminal and Logs: Test the live HTTP response code and monitor server logs for crawler status codes to verify that firewall layers are aligned with robots.txt rules.

Related Technical Resources