Loading...

Skip to content
MemonaIQ
ToolsLearnCompany
Sign in
ToolsLearnCompanyBrowse all tools
Knowledge Center
In this topic
Technical SEO
How to find broken links on your websiteTechnical SEO checklist: crawl, index and page basicsWebsite crawling explained: how crawlers find pagesXML sitemaps: format, limits and what to includerobots.txt rules: syntax, matching and common mistakes
A-Z glossary
HomeKnowledgeTechnical SEO
Technical SEO•4 min read•intermediate

robots.txt rules: syntax, matching and common mistakes

How robots.txt works under RFC 9309: User-agent, Disallow, Allow and Sitemap lines, wildcard matching, why it can't hide pages from search, and where it lives.

What robots.txt controls

robots.txt is a plain-text file at the root of a host that tells crawlers which URL paths they may request. Rules are grouped by user agent, each group lists Allow and Disallow paths, and the most specific matching rule wins. The format is standardized in RFC 9309.

It controls crawling only. It doesn't remove pages from search results, and it isn't access control: compliant crawlers follow it voluntarily, and anyone can still open a blocked URL. The file is public, so listing a secret path in it advertises that path.

Where the file must live

Crawlers look for the file only at /robots.txt at the root of a host, such as https://www.example.com/robots.txt. A robots.txt in a subfolder is ignored.

Rules apply to the protocol, host and port the file is served from. The file on example.com doesn't cover www.example.com or shop.example.com, so each subdomain needs its own.

Status codes matter. If the file returns 404 or another 4xx, RFC 9309 allows crawlers to access everything. Under the same RFC, a 5xx or an unreachable file means crawlers must assume the whole site is disallowed.

Crawlers usually cache the file for up to 24 hours, so changes aren't seen at once. Keep it under 500 KiB, the minimum RFC 9309 requires crawlers to read; Google ignores anything past that.

Syntax: User-agent, Disallow, Allow and Sitemap

Each line is a field name, a colon and a value, and # starts a comment. A group begins with one or more User-agent lines, followed by the Allow and Disallow rules for those crawlers.

A crawler obeys only one group: the one whose User-agent most specifically matches its name. It falls back to the * group only when no named group matches. User-agent names match without regard to case, but paths are case-sensitive.

An empty Disallow allows everything. Sitemap lines stand outside the groups and take a full URL. In the example below, ExampleBot reads only its own group, so it may crawl /admin/ and /search.

Fields outside the standard, such as Crawl-delay, are ignored by Google, though some other crawlers honor them. Google also ignores noindex lines in robots.txt.

robots.txt
text
# Rules for every crawler without its own group
User-agent: *
Disallow: /admin/
Disallow: /search
Allow: /admin/help/

# ExampleBot follows only this group
User-agent: ExampleBot
Disallow: /drafts/

Sitemap: https://www.example.com/sitemap.xml

How rules match: the most specific rule wins

For each URL, the crawler compares its path and query string with every Allow and Disallow rule in its group. The rule with the longest matching path wins. If an Allow and a Disallow rule match with the same length, the Allow rule applies, and a URL that matches no rule is allowed.

Two characters have special meaning. An asterisk (*) matches any sequence of characters, and a dollar sign ($) at the end of a rule anchors it to the end of the URL.

  • Disallow: /private blocks /private, /private/ and /private-notes.html, because rules match by prefix.
  • Disallow: /private/ blocks only URLs inside that folder.
  • Disallow: /*.pdf$ blocks /files/report.pdf but not /files/report.pdf?download=1, since that URL doesn't end in .pdf.
  • Disallow: /*? blocks every URL that has a query string.
  • With Disallow: /admin/ and Allow: /admin/help/, the URL /admin/help/faq is allowed because the Allow rule is longer.

robots.txt vs noindex

Blocking a URL in robots.txt stops compliant crawlers from fetching it, but the URL can still be indexed if other pages link to it. It may then appear in results with no description, since the crawler never read the page.

A noindex directive, in a robots meta tag or an X-Robots-Tag header, tells search engines to keep a page out of results. They see it only if they can fetch the page. Block a page in robots.txt and add noindex, and the noindex is never read.

To remove a page from search, allow crawling and serve noindex, or return 404 or 410, then wait for the page to be recrawled. For content that must stay private, require a login.

The leftover Disallow: / from staging

Staging sites often block every crawler with two lines: User-agent: * followed by Disallow: /. When that file reaches production, compliant crawlers stop fetching the live site, new pages aren't discovered and existing results can lose their descriptions.

Check the production robots.txt right after launch and after any deploy that changes configuration. Better still, generate the file per environment and protect staging with a login, which also keeps it out of search results.

Previous guide
XML sitemaps: format, limits and what to include
MemonaIQ tools

Try it on your own input

Check what this guide describes against your own URL, domain, code or file.

Website Launch Readiness Checker

Check a homepage before launch for a robots.txt that blocks everything, a leftover noindex and a sitemap that won't load. Requires sign-in.

Open tool

References

  • RFC 9309: Robots Exclusion Protocol
  • Google: How Google interprets the robots.txt specification
  • Google Search Central: Block search indexing with noindex

On this page

What robots.txt controlsWhere the file must liveSyntax: User-agent, Disallow, Allow and SitemapHow rules match: the most specific rule winsrobots.txt vs noindexThe leftover Disallow: / from staging
Updated:2026-10-25
Format:Technical Guide
Related tool
Website Launch Readiness Checker

Check a homepage before launch for a robots.txt that blocks everything, a leftover noindex and a sitemap that won't load. Requires sign-in.

Open tool
MemonaIQ

Focused tools for everyday digital work.

  • 18 focused tools
  • 9 run in your browser
Browse all tools Get help

Featured tools

URL Intelligence PlatformImage CompressorInvoice StudioDNS LookupAI Token Counter

Explore

All toolsKnowledge CenterGuidesResourcesCompany

Support

HelpContactSecurity

Legal

PrivacyTermsCookies

© 2026 MemonaIQ. Made in Colombo.

Back to top

MemonaIQ