Googlebot and robots.txt: How Google Reads Your Rules
BY DZAN VOLODER, FOUNDERLAST UPDATED 8 MIN READ
Googlebot reads robots.txt from the root of each host, protocol and port, caches it for up to 24 hours, and follows only the group with the most specific user agent match. Within that group, the rule with the longest matching path wins, and when an Allow and a Disallow tie, Google uses the less restrictive one. robots.txt controls crawling, not indexing: to keep a page out of Google, use noindex.
Where Googlebot looks for robots.txt
robots.txt must sit at the top level of a host, for example https://example.com/robots.txt. Its rules apply only to the host, protocol and port where it is served, so https://www.example.com, http://example.com and https://blog.example.com each need their own file. Google does not look for robots.txt files in subdirectories.
The file must be plain text in UTF-8. Google reads the first 500 kibibytes and ignores anything after that.
Which group of rules Googlebot follows
A robots.txt file is made of groups, each starting with one or more User-agent lines. Googlebot follows exactly one group: the one with the most specific user agent that matches it. If there is a group for Googlebot, it ignores the User-agent: * group completely; the two are not combined. User agent names are matched without regard to case.
User-agent: *
Disallow: /internal/
User-agent: Googlebot
Disallow: /search/
# Googlebot follows only its own group:
# /search/ is blocked, /internal/ is NOT blocked for Googlebot.
This catches many sites out. If you add a Googlebot group, repeat every rule from the * group that should also apply to Google.
How rules are matched
- Longest match wins. Google uses the most specific rule, based on the length of the rule's path. Disallow: /shop with Allow: /shop/sale lets /shop/sale/shoes be crawled.
- Ties go to Allow. When an Allow and a Disallow rule are equally specific, including rules with wildcards, Google uses the least restrictive rule.
- Wildcards. An asterisk matches any sequence of characters and a dollar sign marks the end of the URL. Disallow: /*.pdf$ blocks URLs ending in .pdf.
- Paths are case-sensitive. Disallow: /Admin does not block /admin. Field names such as Disallow are not case-sensitive.
- Only four fields. Google supports user-agent, allow, disallow and sitemap. Crawl-delay is not supported, and Google stopped supporting noindex in robots.txt in 2019.
Caching and error codes
Google generally caches robots.txt for up to 24 hours, longer if it cannot refresh it. What happens when the fetch fails depends on the status code, and the difference between 4xx and 5xx matters a lot.
Status What Google does
2xx Uses the file as served
3xx Follows at least 5 redirect hops, then treats it as a 404
4xx (not 429) Assumes there is no robots.txt: no crawl restrictions
5xx or timeout Stops crawling the site for 12 hours while retrying,
then uses the last good copy for up to 30 days
In other words, a missing robots.txt is harmless, but a robots.txt that returns server errors can pause crawling of your whole site. Check that it returns 200, or a clean 404 if you do not want one.
robots.txt does not remove pages from Google
Disallow stops Googlebot fetching a page, not Google indexing its URL. A blocked URL that other pages link to can still appear in search results, without a description. And because Googlebot cannot fetch it, it never sees a noindex tag on that page.
To keep a page out of Google, allow it to be crawled and add a noindex robots meta tag or X-Robots-Tag header. Use robots.txt to manage crawling, such as stopping Google spending time on endless filter URLs.
Googlebot, Google-Extended and AI features
Google's AI Overviews and AI Mode use the regular Search index that Googlebot builds, so blocking Googlebot also removes you from them. Google-Extended is a separate robots.txt token that controls whether content is used for Gemini model training and grounding in Gemini Apps. Google says it does not affect inclusion or ranking in Google Search.
How to test your robots.txt
- Open the robots.txt report in Search Console to see the version Google fetched, when, and any errors or warnings.
- Use the URL Inspection tool on an important page to confirm it is not blocked by robots.txt.
- Check AI crawlers too: our free AI crawler checker applies Google's matching rules for 18 AI bots.
- After a site migration or redesign, re-check robots.txt first. Leftover staging rules are a classic cause of lost rankings.