Guides · Crawl mechanics

robots.txt: The Rules Crawlers Actually Parse

Last verified: October 2026 · About 10 minutes of reading

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.

What a robots.txt file does and does not cover (Google's documented examples).
File URLCoversDoes not cover
https://example.com/robots.txthttps://example.com/ and all paths below ithttp://example.com/, https://www.example.com/, port 8181
https://www.example.com/robots.txthttps://www.example.com/ onlyhttps://example.com/ and every other subdomain
https://shop.example.com/robots.txthttps://shop.example.com/ onlyThe apex domain and sibling subdomains
https://example.com:8181/robots.txtContent served on port 8181Default-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 under RFC 9309 and Google's parser.
FieldStatusWhat it doesExample
user-agentDefined in RFC 9309Opens a group and names the crawler it applies toUser-agent: *
allowDefined in RFC 9309Permits a path that a shorter rule would blockAllow: /blog/
disallowDefined in RFC 9309Requests that a path prefix not be fetchedDisallow: /cart/
sitemapOutside the RFC; crawlers may read itGives the absolute URL of a sitemapSitemap: https://example.com/sitemap.xml
crawl-delayNot in RFC 9309Requests a gap between requests; support variesCrawl-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.

How one request is resolved when several patterns match.
RuleRequestResultWhy
Disallow: /docs//docs/startBlocked7 matching characters, nothing longer
Disallow: /docs/ plus Allow: /docs/public//docs/public/aAllowedThe Allow pattern is 14 characters, longer than 7
Allow: /page plus Disallow: /page/pageAllowedEqual length: RFC 9309 says Allow should win
Disallow: /*.pdf$/files/report.pdfBlocked* matches any run of characters, $ anchors the end
Disallow: /*.pdf$/files/report.pdf?x=1AllowedThe URL no longer ends at .pdf, so the anchor fails
Disallow: /search/searchingBlockedPatterns 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.

Googlebot's documented behaviour by response status.
StatusGooglebot behaviourWhat to do
200Parses the file and applies the rulesNothing; confirm the body is the file, not an HTML page
3xxFollows at least 5 hops, then treats the result as a 404Serve the file directly instead of redirecting to it
4xx except 429Treated as no robots.txt, so no crawl restrictionsNever use 401 or 403 to slow a crawl
429Treated like a 5xx: crawling stops and the site is temporarily treated as fully disallowed while Google retriesA 429 on /robots.txt is a crawl stop, not a throttle — fix the rate limit
5xx or timeoutStops crawling for 12 hours, then uses the last good copy for up to 30 daysRestore 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.

When a rule does not work: five causes

An ignored rule usually has one of five causes, and none is fixed by rewriting it.

  1. Case sensitivity in paths. Path matching is case-sensitive: Disallow: /Admin does not cover /admin. Fields are case-insensitive; paths are not.
  2. Group merging. A group is defined only by its user-agent lines, and blank lines do not end it — rules meant for one bot can leak into the group above.
  3. Using robots.txt to remove a page. Disallow stops the fetch, so Googlebot never sees a noindex tag on that URL; the page can still appear without content. Blocking and de-indexing differ.
  4. The edge serves a different file. A CDN, WAF or bot layer can intercept /robots.txt and return its own body — diff the fetched copy against your repository file.
  5. 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.

  1. Fetch it as a client would. curl -sI https://example.com/robots.txt should show 200 and text/plain, with no bot challenge or login redirect in the way.
  2. 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.
  3. 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.
  4. 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.

Last verified: October 2026. Parsing rules were checked against RFC 9309 and Google's robots.txt documentation on 2026-10-25; vendor behaviour outside Google is not covered by either source.