What is the meaning of `Disallow: /? in a robots.txt file?
User-agent: *
Disallow: /?*
What is the meaning of `Disallow: /? in a robots.txt file?
User-agent: *
Disallow: /?*
Within a robots.txt file a Disallow
rule blocks crawling and Allow
rules allow crawling. Bots that respect robots.txt files need to compare the path of the current URL with the paths specified in the Disallow
and Allow
rules.
The parsing is quite complex and is described in RFC 9309. The matching must be done case sensitive, the most specific match must be used if Allow
rules and Disallow
rules a equivalent, Allow
should be used.
In your example URLs with a path starting with "/?" will be excluded from crawling.
What's noteworthy here is that due to the wildcard Disallow: /?*
and Disallow: /?
are equivalent, because the path comparison always is a left match.
Here is a table showing the status for some URLs:
URL | status |
---|---|
https://example.com/ |
allowed |
https://example.com/? |
disallowed |
https://example.com/?foo |
disallowed |
https://example.com/foo? |
allowed |
https://example.com/foo/? |
allowed |
Note: If you want to block all URLs with a query the rule is insufficient and Disallow: /*?
must be used instead.