Guides · Crawl mechanics
robots.txt: The Rules Crawlers Actually Parse
Most robots.txt advice is lines to paste. This is the model underneath: which fields the standard defines, why the longest match wins, and why a 500 on one file stops a crawl.
What robots.txt is
robots.txt is a plain-text file at a host's root that states which paths a crawler may fetch; it is a request, not access control.
RFC 9309, published in September 2022, formalises a convention Martijn Koster proposed in 1994. It defines the syntax, the matching algorithm and fetch-failure behaviour — not enforcement: a crawler that ignores the file has broken a convention rather than a lock.
That distinction decides what the file is good for: it reduces crawl load on valueless paths and states intent in machine-readable form. It does not hide a page, protect a document, or remove a URL from an index.
Where the robots.txt file must live
One file per scheme, host and port, served at /robots.txt; a copy in a subdirectory or on another subdomain is never read.
The path is fixed and lowercase: a file at /folder/robots.txt is not a robots.txt file, because crawlers never look in subdirectories. Rules bind to the exact origin that served them, which produces the traps below.
| File URL | Covers | Does not cover |
|---|---|---|
https://example.com/robots.txt | https://example.com/ and all paths below it | http://example.com/, https://www.example.com/, port 8181 |
https://www.example.com/robots.txt | https://www.example.com/ only | https://example.com/ and every other subdomain |
https://shop.example.com/robots.txt | https://shop.example.com/ only | The apex domain and sibling subdomains |
https://example.com:8181/robots.txt | Content served on port 8181 | Default-port HTTPS on the same host |
Two consequences: a site that moved to HTTPS but left its old HTTP file has two independent policies, and a www-to-apex redirect does not merge files — the target's file applies after the redirect.
The four fields, and the one that is not standard
RFC 9309 defines user-agent, allow and disallow; sitemap is an outside record that crawlers may interpret, and Google does.
That vocabulary is the whole language; anything else is an extension or a comment.
| Field | Status | What it does | Example |
|---|---|---|---|
user-agent | Defined in RFC 9309 | Opens a group and names the crawler it applies to | User-agent: * |
allow | Defined in RFC 9309 | Permits a path that a shorter rule would block | Allow: /blog/ |
disallow | Defined in RFC 9309 | Requests that a path prefix not be fetched | Disallow: /cart/ |
sitemap | Outside the RFC; crawlers may read it | Gives the absolute URL of a sitemap | Sitemap: https://example.com/sitemap.xml |
crawl-delay | Not in RFC 9309 | Requests a gap between requests; support varies | Crawl-delay: 10 |
Three details matter more than they look: a sitemap line must not terminate a group; a group with no rules allows everything; and Disallow: with an empty value allows every path while Disallow: / blocks every path.
# A minimal file that states a policy and nothing more
User-agent: *
Disallow: /cart/
Disallow: /search?
Allow: /search/help
Sitemap: https://example.com/sitemap.xml
Matching rules: longest match, wildcards and anchors
The most specific matching rule wins, measured in characters, so an Allow can override a broader Disallow.
Order in the file is irrelevant: RFC 9309 requires the match with the most octets, so the first rule written has no priority. Paths are case-sensitive; matching runs on the percent-encoded URL.
| Rule | Request | Result | Why |
|---|---|---|---|
Disallow: /docs/ | /docs/start | Blocked | 7 matching characters, nothing longer |
Disallow: /docs/ plus Allow: /docs/public/ | /docs/public/a | Allowed | The Allow pattern is 14 characters, longer than 7 |
Allow: /page plus Disallow: /page | /page | Allowed | Equal length: RFC 9309 says Allow should win |
Disallow: /*.pdf$ | /files/report.pdf | Blocked | * matches any run of characters, $ anchors the end |
Disallow: /*.pdf$ | /files/report.pdf?x=1 | Allowed | The URL no longer ends at .pdf, so the anchor fails |
Disallow: /search | /searching | Blocked | Patterns are prefixes, not whole segments |
RFC 9309 requires support for #, $ and *. The comment character needs a warning of its own: everything after # is ignored, so a URL containing a fragment is silently truncated if pasted unescaped.
Group selection is separate from path matching: a crawler uses the group whose token matches its own, falls back to * when none does, and combines rules when several groups name it. A blank line ends a group; a missing one merges the next User-agent line into the previous group.
What happens on 404, 403 and 500
A missing file means no restrictions; a server error means a crawler may assume the whole site is disallowed.
The status code of /robots.txt is a control signal in its own right. Google documents the behaviour per status class, and the results are not symmetric: the harmless-looking failure is the one that stops a crawl.
| Status | Googlebot behaviour | What to do |
|---|---|---|
| 200 | Parses the file and applies the rules | Nothing; confirm the body is the file, not an HTML page |
| 3xx | Follows at least 5 hops, then treats the result as a 404 | Serve the file directly instead of redirecting to it |
| 4xx except 429 | Treated as no robots.txt, so no crawl restrictions | Never use 401 or 403 to slow a crawl |
| 429 | Treated like a 5xx: crawling stops and the site is temporarily treated as fully disallowed while Google retries | A 429 on /robots.txt is a crawl stop, not a throttle — fix the rate limit |
| 5xx or timeout | Stops crawling for 12 hours, then uses the last good copy for up to 30 days | Restore a 200 as fast as possible; the cached copy is what applies meanwhile |
The 5xx path is the outage that looks like a policy decision. A 503 triggers frequent retries, and without a cached copy Google assumes no restrictions. After the 30 days shown above, a reachable site counts as having no robots.txt, while one with availability problems stops being crawled. RFC 9309 is blunter: an unreachable file means assume complete disallow.
Recovery is specific: make /robots.txt return 200 with the correct body, then confirm in Search Console's robots.txt report that Google fetched it. That report has a Request a recrawl action (three-dot menu by the file) which queues an earlier fetch — it does not force one.
Size, encoding and parsing limits
The file must be UTF-8 plain text, and Google reads only the first 500 KiB of it.
RFC 9309 requires a parsing limit of at least 500 kibibytes; Google enforces exactly 500 KiB and ignores everything after it — a generated rule list past that boundary silently becomes a partial policy.
- Encoding. UTF-8 as
text/plain; a BOM is ignored, and non-UTF-8 characters may be dropped in ways that break a rule. - Line endings. CR, LF or CRLF all work; field names are case-insensitive.
- Parse errors. Invalid lines are skipped rather than failing the file, so a typo usually removes one rule, not the policy.
- HTML fallback. If an SPA answers with its HTML shell, Google extracts whatever rules it can and ignores the rest.
When a rule does not work: five causes
An ignored rule usually has one of five causes, and none is fixed by rewriting it.
- Case sensitivity in paths. Path matching is case-sensitive:
Disallow: /Admindoes not cover/admin. Fields are case-insensitive; paths are not. - Group merging. A group is defined only by its
user-agentlines, and blank lines do not end it — rules meant for one bot can leak into the group above. - Using robots.txt to remove a page.
Disallowstops the fetch, so Googlebot never sees anoindextag on that URL; the page can still appear without content. Blocking and de-indexing differ. - The edge serves a different file. A CDN, WAF or bot layer can intercept
/robots.txtand return its own body — diff the fetched copy against your repository file. - The empty
Disallow:. An empty disallow value means allow everything; a blank path from a template silently cancels the restrictions above it.
A sixth failure mode: rules blocking CSS and JavaScript. Googlebot renders pages, so a disallow on asset paths breaks rendering — Search Console reports it as blocked resources. Disallow: / is the extreme case: it stops crawling entirely.
How to test robots.txt without waiting for a crawl
Fetch the file, read the parsed rules back, and treat a 200 as proof of serving, not of obedience.
- Fetch it as a client would.
curl -sI https://example.com/robots.txtshould show 200 andtext/plain, with no bot challenge or login redirect in the way. - Read the policy, not the file. For a few real URLs, work out which rule wins by longest match. The free AI readability check reports the allow or block decision for two paths, alongside sitemap, canonical and noindex.
- Use the engine's own parser. Search Console's robots.txt report shows the version Google fetched, its parse result and syntax warnings — the closest thing to ground truth for Googlebot.
- Watch real requests. Server logs settle what a simulation cannot: whether the crawler arrives, and which paths it asks for afterwards.
What this cannot prove: a 200 proves the file is served, not obeyed; a blocked log line proves one refusal, not compliance at scale; no local test can tell how an uncontacted vendor will treat the file.
robots.txt is not a security mechanism
The file is public and advisory; it cannot protect a document, and listing a private path advertises where it is.
RFC 9309 says the rules are not access authorization, and its security section notes that listing paths makes them discoverable — private content belongs behind authentication or a 404. A disallowed URL can still be indexed from external links, and a disallowed page's noindex can never be read, because the fetch never happens.
Which AI crawlers to allow is a policy decision, covered in the blocking guide along with the crawler identities; this page stays on the mechanics both rely on.
Sources checked
- RFC 9309, Robots Exclusion Protocol (IETF, September 2022) — fields, longest match, unreachable status, 500 KiB limit.
- Google Search Central, "How Google interprets the robots.txt specification" — status codes, host scope, size limit. Checked 2026-10-25.
- Google Search Central, "Build and submit a sitemap" — the Sitemap record is outside the RFC. Checked 2026-10-25.
Frequently asked questions
Five questions cover the misunderstandings that cause the most damage: indexing, crawl-delay, server errors, subdomains and timing.
Does Disallow: / remove a page from Google?
No. Disallow stops the fetch, not the indexing: a blocked URL can still appear without a snippet if other pages link to it. For removal, use noindex and allow the crawl.
Is crawl-delay part of the standard?
No. RFC 9309 defines user-agent, allow and disallow only. crawl-delay is non-standard: some crawlers read it, Google does not. Use the crawl-rate setting in Search Console instead.
What happens if robots.txt returns a 500 error?
Googlebot stops crawling the site for the first 12 hours while it retries, then uses the last good copy for up to 30 days. If the error persists and the site is otherwise reachable, it behaves as if no file exists.
Does a subdomain inherit the main domain robots.txt?
No. Rules apply only to the scheme, host and port that served the file: https://example.com covers neither http://example.com nor https://shop.example.com, so each host needs its own copy.
How long does a robots.txt change take effect?
Crawlers may cache the file, and RFC 9309 says a cached copy should not be used for more than 24 hours — expect a change on the next fetch, not at deploy time.
Check any site free
See how your robots.txt parses, which paths the eight AI crawlers can reach, and whether sitemap and canonical agree.