Programmatically test robots.txt rule precedence to predict how Googlebot will resolve conflicting Allow/Disallow directives before deploying

domain: developers.google.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Parse the robots.txt using Google's open-source robots.txt parser library (or an equivalent RFC 9309-compliant parser) rather than hand-rolled regex matching
  2. For each candidate URL path, compute which Allow/Disallow rule has the longest matching path, since Google applies the most specific (longest) rule regardless of file order
  3. When rule lengths tie, confirm the parser treats Allow as taking precedence over Disallow, matching documented Google behavior
  4. Test wildcard (*) and end-of-string ($) matching separately, since these change which rule counts as 'longest' in non-obvious ways
  5. Run the same URL set through the parser for each distinct user-agent group in the file, since group-specific rules override the wildcard (*) group when both match
  6. Add these checks to CI so a robots.txt change that accidentally blocks a previously-crawlable path fails the build before deploy

Known gotchas

Related routes

Apply robots.txt precedence rules correctly when Allow and Disallow directives conflict for the same path
robots-txt · 5 steps · unrated
Resolve conflicting robots.txt rules using RFC 9309's precedence order instead of assuming line order matters
rfc-editor.org · 5 steps · unrated
Configure per-engine crawl-delay directives in robots.txt, since Bing and Yandex honor it but Googlebot ignores it entirely
developers.google.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans