robots.txt Guide: Syntax, Examples and AI Crawler Rules
robots.txt syntax examples: user agents, Allow and Disallow, wildcards, sitemaps and AI crawler rules, plus the RFC 9309 matching rules most guides skip.
Kazi Khalid Hasan Tamim · BugViso Team
16 min read
A robots.txt file is a plain-text file at the root of your domain that tells crawlers which paths they may fetch. The syntax is User-agent groups with Allow and Disallow rules plus a Sitemap line, as defined in RFC 9309, and the examples below cover AI crawlers such as GPTBot and ClaudeBot too. One stray Disallow: / blocks your whole site.
In 2026, the stakes of managing your robots.txt file are higher than ever. Beyond directing search engine bots like Googlebot, your robots.txt file now dictates how artificial intelligence crawlers (such as OpenAI's GPTBot, Anthropic's ClaudeBot, and PerplexityBot) interact with your content.
A single misconfigured directive can either leak proprietary documentation to AI training models or inadvertently block your brand from appearing in AI-synthesized search answers.
What Is robots.txt? RFC 9309 and the Robots Exclusion Protocol
The robots.txt file is a plain text document placed in the root directory of a web server that communicates crawling restrictions to automated web robots. Formally standardized in 2022 under IETF RFC 9309, the Robots Exclusion Protocol establishes universal rules for crawler discovery, syntax parsing, and error handling.
+-------------------------------------------------------------------------+
| THE ROBOTS.TXT CRAWL PROTOCOL PIPELINE |
| |
| 1. Crawler arrives at domain: `https://example.com/products/item-1` |
| |
| 2. BEFORE requesting the page, crawler fetches: |
| `https://example.com/robots.txt` |
| |
| 3. PARSER CHECKS RULES: |
| +---> Allowed: Proceed to download HTML and render assets. |
| +---> Disallowed: ABORT REQUEST! (Zero bytes transferred). |
+-------------------------------------------------------------------------+According to Google's introduction to robots.txt, robots.txt is primarily a mechanism for managing crawl budget and server bandwidth. It prevents crawlers from overloading your backend infrastructure with low-value, duplicate, or administrative URLs.
Technical File Constraints (RFC 9309):
- Strict File Location: The file must reside at the root domain path (
https://example.com/robots.txt). A file located athttps://example.com/sub/robots.txtis completely ignored. - File Size Limit: Search engines enforce a maximum file size of 500 Kilobytes (KB). Any directives beyond 500KB are truncated.
- Character Encoding: The file must be authored in standard UTF-8 text format.
- Protocol Scope: Each subdomain and protocol scheme requires its own distinct file (e.g.,
https://example.com/robots.txtdoes not governhttps://blog.example.com/robots.txt).
robots.txt Syntax Examples: Core Directives and Rules
A valid robots.txt file consists of directive blocks composed of specific field-value pairs.
Core Directives & Their Protocol Roles
- Directive | Purpose & Syntax
User-agent:| Identifies which crawler the following block applies toDisallow:| Specifies URL paths the crawler is forbidden to requestAllow:| Carves out exceptions within a disallowed directorySitemap:| Declares absolute URL of your XML sitemap index
1. The User-agent: Directive
Defines the target bot. A wildcard asterisk (*) applies the block to all web crawlers unless a more specific bot block is declared:
# Global rule block applying to all web crawlers
User-agent: *
Disallow: /admin/
# Specific rule block for Googlebot (Applebot follows it too when it has no group of its own)
User-agent: Googlebot
Disallow: /internal-search/One exception to "each bot reads its own group": Apple says Applebot obeys your Googlebot group when no User-agent: Applebot group exists. See how Applebot reads robots.txt.
2. Path Matching, Wildcards (*), and Anchors ($)
Modern crawlers support pattern-matching extensions defined in RFC 9309:
- Prefix Matching:
Disallow: /privateblocks/private,/private/,/private-doc.html, and/privatization. - Wildcard (
*): Matches zero or more arbitrary characters. - End-of-URL Anchor (
$): Matches the exact end of a URL path.
# Block all URLs containing the query parameter 'sort='
Disallow: /*?*sort=
# Block all standalone PDF documents across the entire site
Disallow: /*.pdf$3. The Path Precedence Rule: Longest Match Wins
When both Allow: and Disallow: directives match a requested URL, search engines follow the directive with the longest matching character pattern:
User-agent: *
Disallow: /products/
Allow: /products/featured$
# EVALUATION:
# /products/shoes -> DISALLOWED (Matches 10 chars: `/products/`)
# /products/featured -> ALLOWED (Matches 19 chars: `/products/featured$`)4. The Obsolete crawl-delay Directive
The crawl-delay: directive was historically used to slow down crawler request rates. Googlebot completely ignores crawl-delay.
Google automatically calculates crawl rates based on your server's response time (TTFB) and error rates. If you need to manage Googlebot throughput, optimize your backend infrastructure rather than relying on crawl-delay.
Copy-Paste robots.txt Production Templates
Here are three battle-tested configuration templates for different web application architectures:
Template 1: Modern SaaS / B2B Web Application
# Standard Production Robots.txt for Web Applications
User-agent: *
Allow: /
# Disallow internal administrative, API, and authentication endpoints
Disallow: /admin/
Disallow: /api/
Disallow: /auth/
Disallow: /dashboard/
Disallow: /settings/
Disallow: /staging/
# Disallow internal search query parameters
Disallow: /search?*
Disallow: /*?*ref=
# Declare primary XML Sitemap
Sitemap: https://example.com/sitemap_index.xmlTemplate 2: E-Commerce Store with Parameter Filtering
# E-Commerce Optimization: Protect Crawl Budget from Faceted Filters
User-agent: *
Allow: /
# Prevent crawl loops from sorting and filter combinations
Disallow: /*?*sort=
Disallow: /*?*filter=
Disallow: /*?*price=
Disallow: /*?*color=
Disallow: /*?*size=
Disallow: /*?*sessionid=
# Disallow checkout, cart, and account portals
Disallow: /checkout/
Disallow: /cart/
Disallow: /account/
Disallow: /wishlist/
# Declare Sitemaps
Sitemap: https://example.com/sitemaps/sitemap-products.xml
Sitemap: https://example.com/sitemaps/sitemap-categories.xmlTemplate 3: Staging / Pre-Production Environment (Block All)
# Staging Environment: Block All Search Bots & AI Crawlers
User-agent: *
Disallow: /Note: In staging environments, always combine Disallow: / with HTTP Basic Authentication or IP whitelisting to prevent sensitive endpoints from leaking.
Modern AI Search & LLM Crawler Directives (The 2026 AI Landscape)
The rapid rise of AI search engines and Large Language Models has split automated web crawlers into two distinct functional categories:
Ai Training Crawlers Vs Ai Search Agents
-
- LLM TRAINING BOTS | 2. LIVE AI SEARCH / GEO CITATION AGENTS
- Examples:
GPTBot, | Examples:ChatGPT-User,PerplexityBot, ClaudeBot, |Google-ExtendedBytespider|- Purpose: Scrapes data to | Purpose: Fetches real-time web context to
- train future AI models | answer user queries with linked citations
- Commercial Impact: Consumes| Commercial Impact: Drives direct referral
- bandwidth; no clicks | traffic and brand visibility in AI answers
The Major AI User-Agents Matrix
According to the official OpenAI GPTBot documentation and Anthropic ClaudeBot documentation, you can selectively permit or restrict AI agents based on your intellectual property and marketing strategy:
| User-agent string | Operator | Primary purpose |
|---|---|---|
GPTBot | OpenAI | Model training (GPT-5, future LLMs) |
ChatGPT-User | OpenAI | Live web browsing in ChatGPT Search |
ClaudeBot | Anthropic | Training and live context retrieval |
PerplexityBot | Perplexity AI | Real-time AI search indexing |
Google-Extended | Gemini and Vertex AI model training | |
Bytespider | ByteDance | TikTok / Doubao LLM training |
CCBot | Common Crawl | Open-source web scraping archive |
The Strategic Generative Engine Optimization (GEO) Configuration
If your objective is to prevent bulk scraping of your proprietary data while maximizing your brand's visibility in AI search summaries (Perplexity, ChatGPT Search), configure your robots.txt to distinguish between training crawlers and live search agents:
# 1. Allow search engine crawlers and live AI retrieval agents
User-agent: Googlebot
Allow: /
User-agent: Bingbot
Allow: /
User-agent: PerplexityBot
Allow: /
User-agent: ChatGPT-User
Allow: /
# 2. Block pure AI model training scrapers (Protects IP & saves bandwidth)
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: Bytespider
Disallow: /
User-agent: CCBot
Disallow: /
# 3. Global Default Rules
User-agent: *
Allow: /
Disallow: /admin/
Sitemap: https://example.com/sitemap_index.xmlTesting, Validating, and Debugging robots.txt
Before deploying changes to production, you must validate that your syntax complies with RFC 9309 and does not inadvertently block critical rendering assets.
Robots.Txt Testing Workflow
- Check live file delivery via cURL: run
curl -I https://example.com/robots.txtand verify HTTP 200 OK andContent-Type: text/plain. - Inspect the Google Search Console robots.txt report: check for syntax warnings and historical fetch timestamps.
- Test specific URL paths via the URL Inspection tool: verify Googlebot can fetch critical CSS, JS and HTML.
To diagnose why pages may fail to appear in search results despite valid syntax, consult our comprehensive guide on why is my page not indexed? technical audit guide.
How BugViso Audits Robots.txt and AI Search Readiness
When you sign in and scan your site with BugViso, the crawler checks your technical directives for both search and AI crawlers:
- AI crawler access: it evaluates
robots.txtagainst major AI user-agents (GPTBot, ClaudeBot, PerplexityBot, Google-Extended) using RFC 9309 matching, checks for a valid/llms.txt, and gives a 0 to 100 GEO citability score. - Blocked resources: it flags a site-wide
Disallow: /and CSS or JavaScript files thatrobots.txtblocks but pages need to render. - Sitemap declaration: it checks that your
sitemap.xmlor sitemap index is declared and reachable. For sitemap upkeep, see our guide on XML sitemaps: how to create, submit & maintain them. - Fix list: findings are ranked, with AI-written fixes, in the report and the branded PDF.
More detail is on the GEO audit for AI search feature page.
Common robots.txt Mistakes That Destroy SEO
Avoid these frequent engineering traps when managing robots.txt:
| Common Mistake | Consequence |
|---|---|
| Blocking CSS and JS Bundles | Breaks mobile rendering in Googlebot |
| Using File for Security | Publicly reveals secret admin paths |
Disallowing noindex Pages | Traps bare URL in Google Search index |
| Missing Leading Slashes | Breaks path matching across subpaths |
1. Blocking CSS and JavaScript Assets
Years ago, blocking /assets/ or /js/ was common to conserve bandwidth. Today, Googlebot operates as a full rendering engine. If Googlebot cannot download your CSS and JavaScript files, it cannot compute your layout, detect mobile responsiveness, or execute client-side hydration, resulting in catastrophic ranking drops.
2. Using robots.txt for Security or Secret URLs
The robots.txt file is publicly accessible to anyone on the internet. Adding Disallow: /super-secret-admin-portal-v2/ does not protect the page; it publicly advertises the exact path to malicious attackers. Use server-level authentication (OAuth, HTTP Basic Auth) to protect private endpoints.
3. Believing robots.txt Disallow Guarantees De-Indexation
robots.txt prevents crawlers from downloading a page, but it does not prevent Google from indexing the URL. If other websites link to https://example.com/disallowed-page, Google may index the bare URL without a description.
To guarantee de-indexation, allow the page to be crawled and include a <meta name="robots" content="noindex"> tag.
Frequently Asked Questions About robots.txt
Does robots.txt stop Google from indexing a URL?
No. robots.txt prevents Googlebot from crawling and downloading the page content. However, if the disallowed URL has external backlinks or internal links pointing to it, Google can still index the bare URL in search results without a snippet.
To completely remove a page from the index, use a noindex tag and keep the page crawlable.
What is the difference between Disallow: / and Disallow:?
Disallow: /blocks crawlers from accessing every URL on the domain (the entire site).Disallow:(with an empty path) means nothing is disallowed, permitting crawlers to access all pages on the domain.
Where must the robots.txt file be located?
The robots.txt file must be located in the root directory of your website domain (https://example.com/robots.txt). Search engine bots will not look for or obey robots files placed in subdirectories (e.g., https://example.com/blog/robots.txt).
Should I block AI crawlers like GPTBot and ClaudeBot?
It depends on your business goals. If you want to prevent AI companies from scraping your content to train foundation models, block GPTBot and ClaudeBot.
However, if you want your content to be cited and linked as a real-time source in AI search engines (like ChatGPT Search and Perplexity), you should allow search agents like ChatGPT-User and PerplexityBot.
Can I have different robots.txt rules for mobile vs desktop Googlebot?
No. Googlebot uses a single unified crawler infrastructure for both mobile and desktop crawling and does not distinguish between user agents for robots parsing. Standardize all Google directives under User-agent: Googlebot.
robots.txt is the first file a crawler reads, so it belongs at the start of any technical SEO for beginners audit. Pair it with a well-kept XML sitemap, and remember that blocking crawling is not the same as keeping a page out of the index; see the selective indexation strategy.
Summary and Action Plan
Your robots.txt file is the front gate of your technical web architecture: declare clear user-agent blocks according to RFC 9309, avoid blocking critical CSS and JavaScript rendering assets, protect crawl budget by filtering combinatorial query parameters, declare your primary sitemap index, and strategically manage AI search crawlers to maximize brand visibility in Generative Engine Optimization (GEO).
To check for accidental crawl blocks and score your AI crawler readiness, sign in and run a BugViso scan.
Written by
Kazi Khalid Hasan Tamim · BugViso Team
Kazi writes BugViso’s guides on website audits, Core Web Vitals, technical SEO, accessibility and AI search. The data in them comes from audits BugViso runs in a real Chromium browser, including our 219-site study of website health.
Summarise with AI
Open this guide in your assistant.
Follow BugViso
New guides and audit data as we publish them.
AI visibility tracker
Is your brand in AI answers?
See how often AI assistants mention you, cite your site and rank you against your competitors.
- ChatGPT
- Gemini
- Perplexity
- Claude
- AI Overviews
See where your site stands
Run a free BugViso audit for SEO, speed, accessibility and AI search readiness — with fixes you can ship today.