Home / Guides / How to Test a robots.txt File

Updated

How to Test a robots.txt File (Allow, Disallow and AI Crawlers)

Fetch /robots.txt from the bare domain over HTTPS, find the group that names the crawler (or the * group if none does), then apply the rule with the longest matching path; on a tie, Allow wins. Check the HTTP status too: a 404 allows everything, a 5xx blocks everything. Test each crawler by name, because a named group replaces the * group instead of adding to it.

1. Fetch the file the crawler sees

curl -sL -o robots.txt -w '%{http_code} %{url_effective}\n' https://example.com/robots.txt

Note the status code and the final URL. robots.txt applies only to the host, protocol and port it is served from: www.example.com and example.com each need their own file. Crawlers must parse at least 500 KiB; rules beyond that limit may be ignored.

2. Pick the right group

A group starts with one or more User-agent lines. A crawler follows the group that names it (case-insensitive) and ignores User-agent: * entirely. Several groups naming the same crawler are merged.

User-agent: *
Disallow: /private/
Allow: /private/public-page

User-agent: GPTBot
Disallow: /

Here GPTBot is blocked from the whole site, while ClaudeBot, which has no group of its own, follows the * group.

3. Apply the longest match

Among the rules of that group, the one with the longest matching path decides. In the example above, /private/public-page is allowed for ClaudeBot (the Allow rule is longer), and /private/x is blocked. * matches any sequence of characters and $ anchors the end of the URL. With no matching rule, the URL is allowed.

4. A pitfall in Python

We ran the example through Python 3.11's urllib.robotparser on 2 December 2026: it answered False for ClaudeBot on /private/public-page, because it stops at the first matching line. A parser that follows RFC 9309, such as Google's open-source robotstxt library or the one in our audit, answers True. If your script uses robotparser, put Allow lines before the Disallow lines they override, or use an RFC 9309 parser.

5. Error codes change everything

6. Test AI crawlers in bulk

Policies really differ per crawler: on 2 December 2026 lemonde.fr blocked ClaudeBot, Google-Extended and CCBot but allowed GPTBot (details in Is your website ready for AI crawlers?). Plainprobe Website SEO & AI Readiness Audit applies RFC 9309 to the robots.txt of each site for 12 AI crawlers and returns, per crawler, allowed or blocked and the rule that decided, at $0.003 per audited page. For one site, the robots.txt report in Google Search Console shows how Google fetched your file.

FAQ

Which rule wins when Allow and Disallow both match?

Under RFC 9309 the rule with the longest matching path wins; if an Allow and a Disallow rule are equally long, Allow wins. The order of the lines in the file does not matter.

Is the user-agent name case-sensitive?

No. Crawlers match their product token case-insensitively, so GPTBot, gptbot and GPTBOT name the same group.

Does a GPTBot group inherit the rules of User-agent: *?

No. A crawler that finds a group with its own name follows only that group and ignores the * group. Repeat any shared rules inside the named group.

What happens if robots.txt returns an error?

RFC 9309: a 4xx answer (such as 404) means crawlers may fetch everything; a 5xx answer or a network error means they should assume the whole site is disallowed.

Can I test robots.txt with Python's urllib.robotparser?

Only roughly. In Python 3.11 it applies the first matching rule instead of the longest one, so it can disagree with Google and with RFC 9309 on sites that mix Allow and Disallow.

Related tool