How to validate robots.txt: a nine-step procedure
Validate robots.txt in nine steps: fetch status, scope, size, encoding, supported fields, grouping, matching, URL tests and a pre-deploy diff of verdicts.
Validate robots.txt by fetching it over HTTP and checking status, location, size, encoding, fields, grouping and matching, then testing individual URLs against both the live file and a draft. Syntax alone is not validation: a file can parse cleanly and still return the wrong verdict for the wrong bot. The nine steps below run in that order because each one narrows the cause. A 404 makes syntax irrelevant, and a file over 500 KiB loses its tail no matter how clean the syntax is.
Step 1: fetch the file and read the status class
Start with a plain request. Google fetches robots.txt with an HTTP non-conditional GET, so a browser tab or an editor preview is not evidence.
curl -sS -o /dev/null -w '%{http_code} %{content_type} %{size_download}\n' https://www.example.com/robots.txt
The status code decides how much of the rest matters.
| Response | What Google does |
|---|---|
| 2xx | Processes the file as served |
| 3xx | Follows at least five redirect hops, then treats the file as a 404 |
| 4xx, except 429 | Treats it as if no robots.txt exists, so there are no crawl restrictions |
| 429 | Left out of the 4xx rule above; Google’s crawl-rate guidance treats it as a slow-down signal |
| 5xx, DNS or network failure | Stops crawling for 12 hours while retrying, then uses the last good copy for up to 30 days |
“Google follows at least five redirect hops as defined by RFC 1945 and then stops and treats it as a 404 for the robots.txt file.” Frames, JavaScript and meta-refresh redirects are not followed at all, so a redirect built in the page cannot move the file.
If errors last more than 30 days and the site is otherwise reachable, Google behaves as if there is no robots.txt. If the site has general availability problems, it stops crawling while still requesting the file. RFC 9309 describes the same states with different consequences: unavailable (400 to 499) lets the crawler access anything, while unreachable (500 to 599 or network errors) means “the robots.txt file is undefined and the crawler MUST assume complete disallow.” Google matches that for the first 12 hours, then falls back to its last good copy instead of staying fully blocked.
Step 2: confirm location and scope
The file must sit at /robots.txt on the exact host, protocol and port it governs. “You must place the robots.txt file in the top-level directory of a site, on a supported protocol. The URL for the robots.txt file is (like other URLs) case-sensitive.” A copy at /blog/robots.txt is ignored because “Crawlers don’t check for robots.txt files in subdirectories.”
Scope is narrow: “The rules listed in the robots.txt file apply only to the host, protocol, and port number where the robots.txt file is hosted.” That means https://example.com/robots.txt does not govern http://example.com, www.example.com or a staging host. Standard ports are equivalent to default hostnames: 80 for HTTP, 443 for HTTPS and 21 for FTP.
Check each environment separately. The classic launch failure is the staging file, which disallows everything, shipping to production.
Step 3: check size, encoding and line endings
“Google enforces a robots.txt file size limit of 500 kibibytes (KiB). Content which is after the maximum file size is ignored.” RFC 9309 requires parsers to support at least the same limit.
curl -sS https://www.example.com/robots.txt -o /tmp/robots.txt
wc -c /tmp/robots.txt
file -I /tmp/robots.txt
head -c 3 /tmp/robots.txt | xxd
“The robots.txt file must be a UTF-8 encoded plain text file and the lines must be separated by CR, CR/LF, or LF.” Google ignores a byte order mark along with other invalid lines. Strip it anyway, so every parser that reads the file sees the same first line. Non-UTF-8 characters can make rules invalid: “Google may ignore characters that are not part of the UTF-8 range, potentially rendering robots.txt rules invalid.”
Step 4: audit the fields Google supports
“Google supports the following fields (other fields such as crawl-delay aren’t supported):” user-agent, allow, disallow and sitemap. Everything else is either ignored or belongs to another crawler. A crawl-delay line is common in older files; Google does not support it. Its history and what other crawlers do with it are covered in crawl-delay in robots.txt.
Field names are case-insensitive, and so is the user-agent value: “Both the user-agent field name and its value are case-insensitive.” Path values are not. “The path value must start with / to designate the root and the value is case-sensitive.” A rule without a leading slash is ignored, and so is a rule with no path.
Sitemap lines are special. “The sitemap field isn’t tied to any specific user agent and may be followed by all crawlers, provided it isn’t disallowed for crawling.” A sitemap line also does not end the group it sits in, because “Rules other than allow, disallow, and user-agent are ignored by the robots.txt parser.”
Check that no noindex directive appears in the file. It is not a supported field. The difference between blocking and deindexing is covered in noindex vs disallow.
Step 5: read groups, not lines
A robots.txt is a set of groups. Google uses “the group with the most specific user agent that matches the crawler’s user agent. Other groups are ignored.” Group order in the file is irrelevant. Groups for the same user agent merge, but “User agent specific groups and global groups (*) are not combined.”
That last rule catches people. If Googlebot has its own group, the * group does not apply to Googlebot at all, even for paths the specific group never mentions. Write the specific group as a complete policy, or leave it out.
One more exception: “Using an asterisk (*) matches all crawlers except the various AdsBot crawlers, which must be named explicitly.” If AdsBot matters to a client, validate its group separately.
RFC 9309 says the same in normative language: “Crawlers MUST use case-insensitive matching to find the group that matches the product token and then obey the rules of the group.” If no group matches, crawlers must obey the * group when one is present.
Step 6: apply the matching rules
For a URL inside the chosen group, the crawler picks a rule by path length. “crawlers use the most specific rule based on the length of the rule path. In case of conflicting rules, including those with wildcards, Google uses the least restrictive rule.” RFC 9309 agrees: “The most specific match found MUST be used. The most specific match is the match that has the most octets.” It also says an allow rule SHOULD be used when it ties with a disallow rule.
Only two wildcard characters exist. “* designates 0 or more instances of any valid character” and “$ designates the end of the URL.” There is no regular expression syntax. Matching is case-sensitive, so /Fish.asp is not covered by /fish. Raw UTF-8 paths and percent-encoded paths are equivalent: “Disallow: /foo/bar/ツ and Disallow: /foo/bar/%E3%83%84 are treated identically by the parser.”
A worked table helps reviewers spot intent:
| Rule | URL | Verdict |
|---|---|---|
| Disallow: /search | /search-help | Blocked: prefix match |
| Disallow: /search$ | /search-help | Allowed: $ anchors the end |
| Disallow: /*.pdf$ | /guide.pdf | Blocked |
| Disallow: /*.pdf$ | /guide.pdf?x=1 | Allowed: the query comes after the anchor |
| Allow: /search and Disallow: /search | /search | Allowed: equal length, allow wins |
Step 7: test real URLs against the live file and the draft
Syntax checkers stop at parsing. The question that matters is which URLs change verdict. Build a list that covers a home page, a category, a product, a search URL, a PDF, an API endpoint, an image, and one URL that should stay blocked. Run the same list against the live file and the draft.
The robots.txt tester tests up to 100 URLs (or the file’s own sitemap URLs) against a live robots.txt or a draft you paste, for 11 crawlers, and shows the rule that decided each verdict. Do this per bot, not once: Googlebot, Googlebot-Image, AdsBot-Google, Bingbot, GPTBot, ClaudeBot and PerplexityBot can all get different answers. The AI crawler checker covers the AI user agents, and what replaced the old Google tester explains why the old workflow ended.
Record the matched rule, not only blocked or allowed. A verdict with no rule behind it is hard to review and harder to explain to a client.
Step 8: diff old and new before deploy
Put the current file and the candidate side by side. The robots.txt tester takes a proposed file and lists only the URL and crawler pairs whose verdict flips, with the deciding rule and line number. Only those rows need a decision.
A pre-deploy diff catches the expensive mistakes: a wildcard that now covers the whole catalogue, a new named group for one bot that silently drops every * rule for that bot, a Disallow that lost its trailing $. If a client site is mid-migration, compare the new host too, because scope is per host and protocol. Robots.txt changes that silently deindex sections lists the patterns that keep causing this.
Keep the diff with the change ticket. When organic traffic moves two weeks later, the diff is the evidence of what changed.
Step 9: watch the file after deploy
“Google generally caches the contents of robots.txt file for up to 24 hours, but may cache it longer in situations where refreshing the cached version isn’t possible.” The cache lifetime can also follow headers: “Google may increase or decrease the cache lifetime based on max-age Cache-Control HTTP headers.”
So a correct deploy can look broken for a day. Watch the live file after release rather than assuming the first fetch settles it. stillindexed reads robots.txt every hour and confirms a new block on a monitored URL with a second read about five minutes later, then alerts by email or Telegram. Setup is on monitor robots.txt. If Google has already reported a block, the status page for blocked by robots.txt explains what the report does and does not mean.
Two myths to drop
The first is that robots.txt supports regular expressions. It does not. Google documents exactly two wildcard characters, * and $, and says the path value is matched by length and case. A validator that accepts .* or character classes and reports a match is testing a dialect Google does not implement.
The second is a statistic. One validator cites a figure, attributed to Google, that 73% of robots.txt files contain a syntax error. The number could not be traced to any Google source. Treat unsourced percentages on tool landing pages as marketing, and check the primary specification instead.
Validation checklist
[ ] 200 response, no redirect chain
[ ] Served at /robots.txt on the exact host, protocol and port
[ ] Scope covers www and apex separately
[ ] Under 500 KiB
[ ] UTF-8, no BOM, LF or CRLF line endings
[ ] Only user-agent, allow, disallow and sitemap fields
[ ] Every path starts with /
[ ] No crawl-delay or noindex lines
[ ] Specific groups complete, not relying on *
[ ] AdsBot named explicitly if needed
[ ] Longest match and allow-on-tie verified on a URL list
[ ] Live and draft tested per bot, matched rule recorded
[ ] Old vs new diff reviewed, verdict changes signed off
[ ] Post-deploy fetch checked after the cache window
Sources
- Google robots.txt specification
- How to create a robots.txt file
- Google crawl rate guidance
- RFC 9309: Robots Exclusion Protocol
- RFC 9309 information page
Read next
Questions
- Can I use regular expressions in robots.txt?
- No. Google's parser supports only two wildcard characters: * matches zero or more characters, and $ matches the end of the URL. Patterns such as .* or [0-9]+ are not regular expressions here, so a line written that way will not match what you expect.
- What happens if robots.txt returns a 500 error?
- Google stops crawling for the first 12 hours while it keeps retrying the file. It then uses the last good copy for up to 30 days. If errors continue beyond that and the site is otherwise reachable, Google behaves as if no robots.txt exists. RFC 9309 is stricter and says an unreachable file means complete disallow.
- Is robots.txt case-sensitive?
- It depends on the part. Google treats field names and user-agent values as case-insensitive, so User-agent and user-agent behave the same. Path values and the matching itself are case-sensitive, so /Fish does not match /fish. The file name and URL are lowercase and case-sensitive as well.
- Does a disallowed URL still get indexed?
- Yes. A Disallow rule prevents crawling, not indexing. Google may still index the URL and show it in search results without a snippet. Blocking a URL is therefore the wrong tool when the goal is removal from the index; the two controls solve different problems.
- How large can a robots.txt file be?
- Google enforces a limit of 500 kibibytes. Anything after that point is ignored, so a long list of rules can silently lose its tail. RFC 9309 requires parsers to support at least the same 500 KiB. Check the byte count before deploy, not the line count.
- Why do robots.txt changes take so long to apply?
- Google generally caches the file for up to 24 hours, and may cache it longer when it cannot refresh. Cache-Control max-age headers can shorten or lengthen that window. If a change must take effect sooner, test the draft before deploy rather than relying on a fast refresh after it.