Skip to content
Mikoshi SEO Mikoshi SEO

Googlebot and robots.txt: How Google Reads Your Rules

BY DZAN VOLODER, FOUNDERLAST UPDATED 8 MIN READ

A robots.txt file with Googlebot's matching group highlighted and the longest matching rule deciding whether a URL can be crawled
THE SHORT ANSWER

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.

  1. [1]Google Search Central: How Google interprets the robots.txt specification

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.

ROBOTS.TXT // GROUP MATCHING
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.

  1. [1]Google Search Central: How Google interprets the robots.txt specification

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.
  1. [1]Google Search Central: How Google interprets the robots.txt specification
  2. [2]Google Search Central Blog: A note on unsupported rules in robots.txt, July 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.

GOOGLEBOT // ROBOTS.TXT STATUS CODES
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.

  1. [1]Google Search Central: How Google interprets the robots.txt specification

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.

  1. [3]Google Search Central: Introduction to robots.txt
  2. [4]Google Search Central: Block search indexing with noindex

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.

  1. [5]Google: Google's common crawlers, including Google-Extended
  2. [6]Google Search Central: AI features and your website

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.
  1. [7]Search Console Help: robots.txt report
  2. [8]Search Console Help: URL Inspection tool

FAQ

Google generally caches robots.txt for up to 24 hours. You can ask for a faster recrawl of the file from the robots.txt report in Search Console.

FREE // AI VISIBILITY SNAPSHOT

See who AI recommends instead of you.

Free snapshot within 2 business days.