Which wins in robots.txt, Allow or Disallow?
By TechCompare · Updated · How we check
The most specific rule wins, which means the one with the most characters in its pattern. On a tie, Allow wins.
When both an Allow and a Disallow rule match a path, the longer pattern wins. If they're the same length, Allow wins. The order of the lines inside a group doesn't change that. RFC 9309 and Google's documentation agree, and the tester shows the rule it used for every verdict.
How it works
Take a group with Disallow: /shop/ and Allow: /shop/sale/. A page at /shop/sale/shoes matches both. The Allow pattern is 11 characters and the Disallow is 6, so the page is allowed. A page at /shop/new matches only the Disallow, so it's blocked. Swap the two lines and nothing changes. RFC 9309 says the most specific match must be used, measured by the most octets, and that on a tie between equivalent rules the allow rule should be used. Google says it uses the longest matching path, and the least restrictive rule if conflicts remain. A broad block with a narrow exception works the same way: Disallow: / with Allow: /public/ blocks the site and lets /public/ pages through. Rules only compete inside one group. If a group is made for the crawler, the * group is ignored for it, and the two are never combined. Rules in other groups can't beat the ones it reads. One path is always allowed: /robots.txt itself.
Verdict
Make the rule you want to win the longer one, then test two paths, one that should be allowed and one that shouldn't, with the crawler you care about. The tester names the line that decided each verdict, so a wrong guess shows up at once.
More Robots.txt scenarios
Frequently asked questions
Does the order of lines matter?
Do rules in different groups compete?
What happens when two rules have the same length?
Related tools
Open Graph Visualizer
Preview how your website links will look when shared on Google, Twitter, Facebook, and Discord.
Use toolSSL Checker
Check a site's certificate, TLS versions, HTTP/2 and HTTP/3 support, post-quantum key exchange, HSTS and redirects, or compare two sites.
Use toolDNS Lookup
Look up a domain's DNS records on Cloudflare or compare several resolvers at once, and read its SPF, DMARC and DKIM records in plain words.
Use tool