Try a pattern
The paths below come from Google’s own wildcard table. Change the rule and watch which ones it catches.
2 of 15 paths match (and would be blocked).
- /allowed
- /fishallowed
- /fish.htmlallowed
- /fish/salmon.htmlallowed
- /fishheadsallowed
- /fish.php?id=anythingallowed
- /Fish.aspallowed
- /catfishallowed
- /?id=fishallowed
- /index.phpblocked
- /folder/filename.phpblocked
- /filename.php?parametersallowed
- /filename.php/allowed
- /windows.PHPallowed
- /fishheads/catfish.php?parametersallowed
How matching works
- Rules are compared from the start of the path, including the query string.
/fishmatches/fish.php?id=1but not/catfish. *matches zero or more of any character, including/and?. A trailing*changes nothing:/fish*equals/fish.$is only special at the very end./*.php$matches/a.phpbut not/a.php?x=1.- Paths are case-sensitive:
/*.phpdoes not match/windows.PHP. - Non-ASCII characters are compared in percent-encoded form, so
/caféand/caf%C3%A9are the same rule (RFC 9309 §2.2.2).
Wildcards and precedence
When Allow and Disallow both match, the longer rule path wins, and * counts as a character. That’s why Disallow: /*.htm (6 characters) beats Allow: /page (5) for /page.htm. Step through all six of Google’s cases in the tester.
Common mistakes
Disallow: *.pdf: no leading slash. Write/*.pdf.Disallow: /*?blocks every URL with a query string, including paginated and tracked links you may want crawled.Disallow: /private*/works, but/privatealone already covers/private-files/and/privately. Be sure that’s what you want.- Expecting
$to work mid-path, as in/a$b. It’s taken literally there.
Questions
Does robots.txt support regular expressions?
No. Only * (any characters) and $ (end of URL). Characters like ?, + and . have no special meaning.
Do all crawlers support wildcards?
RFC 9309 requires * and $, and Google, Bing and other major search engines support them. Very old or simple crawlers may treat them literally.
Sources: Google: URL matching based on path values; RFC 9309 §2.2.3 Special characters.