Technical SEO

Robots.txt disallow all: the two-line rule, and when not to use it

User-agent: * plus Disallow: / blocks every compliant crawler from your whole site. Here's when that's right, when it backfires, and how to undo it.

// in this article

To block every crawler from your whole site, put two lines in the robots.txt file at your domain’s root: User-agent: * and Disallow: /. Every search engine bot that follows the robots.txt standard will then stop fetching your pages, though it won’t make Google forget the URLs it already knows.

User-agent: *
Disallow: /

That rule is right for a few narrow cases and wrong for almost every live business site. Below is what it actually does, the near-miss that does the opposite, the variations people usually want instead, and how to back out of it fast if it ended up on production by mistake.

What the two lines do

User-agent: * starts a group that applies to any crawler without a more specific group of its own. Disallow: / matches every path on the site, because every URL path starts with a slash. Google’s list of useful robots.txt rules gives exactly this pair as the way to disallow crawling of the entire site.

Three details catch people out:

  • It’s per host. The file only governs the host it sits on. RFC 9309, the robots.txt standard published in September 2022, says it must live at /robots.txt, all lowercase, in the top-level path. A block on staging.example.com/robots.txt does nothing to www.example.com, and the reverse.
  • AdsBot isn’t included. Google notes that the wildcard “doesn’t match the various AdsBot crawlers, which must be named explicitly.” If you run Google Ads and want those bots out too, add a group for them by name.
  • A named group replaces the wildcard. Google’s robots.txt spec says a crawler uses “the group with the most specific user agent that matches,” and “only one group is valid for a particular crawler.” So if the same file also has a User-agent: Googlebot group with looser rules, Googlebot follows that group and ignores your disallow all.

One character away from allow all

The most common robots.txt accident is the empty disallow. Google’s spec says “crawlers ignore rules without a [path],” so Disallow: with nothing after it blocks nothing. It’s the classic way to write “allow everything,” which means the two files below look nearly identical and do opposite things.

✕ Disallow all (with a slash)
User-agent: *
Disallow: /
Every compliant crawler stops fetching every page. On a live site, traffic from search drains away.
✓ Allow all (no slash)
User-agent: *
Disallow:
The empty rule is ignored, so nothing is blocked. Same result as having no robots.txt at all.
fig 1 · one slash separates blocking everything from blocking nothing, per google's robots.txt spec

If you want to allow everything, the clearest options are Allow: / or no robots.txt file at all. Google’s robots.txt report help says not having the file is fine, because Google can then crawl all URLs. Before you upload either version, run your key URLs through a parser as shown in our robots.txt testing guide.

Disallow all doesn’t remove you from Google

This is the exception that matters most. Blocking crawling and blocking indexing are different jobs. Google’s robots.txt introduction says robots.txt “is not a mechanism for keeping a web page out of Google,” and that a blocked URL can still show up in results, without a description, if other pages link to it.

In Search Console that shows up as “Indexed, though blocked by robots.txt” in the Page indexing report. Google’s fix for pages you want gone is to “remove the robots.txt block and use ‘noindex’,” because a crawler that can’t fetch a page never sees the noindex tag on it. Our robots.txt noindex article covers that swap in detail, and the Page indexing report guide explains the other statuses you’ll see.

WordPress learned the same lesson. Its “Discourage search engines from indexing this site” box used to write Disallow: / into robots.txt. Since WordPress 5.3 it prints a noindex,nofollow robots meta tag instead, because, as the core team put it, a blocked site can still be listed. See our WordPress robots.txt guide if your site runs on it.

Disallow all is not security either. RFC 9309 says plainly that the rules “are not a form of access authorization.” Well-behaved crawlers obey it, while scrapers and bad bots can ignore it, and anyone can read your robots.txt to see which paths you’re hiding.

When disallow all is the right call

Staging or dev copy Fine as a second layer. Put a password on it first, since links can still get it listed. ok, with a login
Site not launched yet Works if nobody links to it. Put "remove the block" on the launch checklist. ok, briefly
Pausing the business Don't. Google says a disallow all file "may remove the website's content" from Search. use a 503 instead
Hiding a few pages Too blunt. Block the folder, or noindex the pages so they leave the index. use a narrower rule
fig 2 · four reasons people reach for disallow all, and which ones hold up, per google's robots.txt intro and pause guidance

The pause case deserves a closer look, because it’s where small businesses get hurt. Google’s guidance on pausing a site says to “continue to allow crawling through the robots.txt file,” and warns that “there’s no fixed time for a recovery from a complete removal.” If you must take the whole site offline for a day or two, it recommends a 503 error page, and it warns against returning a 503 for robots.txt itself, “because this blocks all crawling.” Say a made-up accounting firm closes for two weeks after tax season. The better move is to leave the site up with a banner about the dates, not to block crawlers.

The rules you probably want instead

Most people searching for “disallow all” want something slightly narrower. These three come straight from Google’s useful rules page.

only one bot allowed
User-agent: Googlebot
Allow: /

User-agent: *
Disallow: /
one bot blocked
User-agent: BadBot
Disallow: /

User-agent: *
Allow: /
all but one folder
User-agent: *
Disallow: /
Allow: /public/
fig 3 · three narrower versions of disallow all, adapted from google's useful robots.txt rules (bot names are examples)

The third one works because Google picks the most specific matching rule by path length, so Allow: /public/ beats Disallow: / for URLs in that folder. When an allow and a disallow are equally specific, Google’s spec says it uses “the least restrictive rule.” If you’re trying to keep AI bots out while staying in Google, don’t use disallow all at all. Name each bot in its own group, as our AI crawler guide lists them.

How to undo a disallow all on a live site

If a launch or migration carried the staging file over to production, fix it in this order:

  1. Replace the file. Remove Disallow: / from the User-agent: * group, or delete the file, and load yourdomain.com/robots.txt in a browser to confirm the live version changed. Clear any CDN or caching plugin first if it still shows the old one.
  2. Check it doesn’t return a server error. Google treats a 4xx robots.txt (except 429) as if no file exists, but on a 5xx it stops crawling the site for the first 12 hours and can fall back on the last cached copy, your disallow all, for up to 30 days.
  3. Ask Google to re-read it. In Search Console, open the robots.txt report (it lives in Settings), click the three-dot menu next to the file and choose “Request a recrawl.” Google says it caches robots.txt “for up to 24 hours,” so this mainly saves you part of that wait.
  4. Request indexing for your most important pages with URL Inspection, keeping in mind Google’s note that there’s a quota for individual URLs.
  5. Resubmit your sitemap so Google rediscovers everything else. Google’s recrawl guide says crawling “can take anywhere from a few days to a few weeks,” and that asking again for the same URL won’t speed it up.

Step 2 is the one people skip. A robots.txt that errors after the fix can keep the old block in force for weeks, so check the status code, not just the text on screen. For a broader post-launch check, our guide to getting a site indexed walks through the rest.

FAQ

Does Disallow: / block every bot?

It blocks any crawler that follows the robots.txt standard and has no more specific group of its own in your file. Crawlers that ignore the standard aren’t stopped, because robots.txt is a request, not access control.

How do I disallow all crawlers except Google?

Add a User-agent: Googlebot group with Allow: / above a User-agent: * group with Disallow: /. Googlebot follows its own named group, and every other compliant bot falls back to the wildcard block.

How long does it take Google to recover after I remove a disallow all?

Google usually picks up the new file within a day, since it caches robots.txt for up to 24 hours. Recrawling the pages themselves can take days to weeks, and Google gives no fixed recovery time if the site had already dropped out.

Keep the block off production

Disallow all is a staging tool, and even there it should sit behind a password. On a live site, block only the folders or bots you mean to, use noindex for pages that must leave the index, and add “check robots.txt” to every launch and migration checklist so the two-line rule never ships by accident.

Portrait of Liam Fraser
// written byLiam FraserSEO specialist with 3 years of experience. Liam writes about what works in local, technical and AI search.About SerpSurfers →