You add one line to robots.txt, push it, and two days later Search Console says half your product pages are "Blocked by robots.txt". Or the opposite: you meant to keep a folder out of Google and it is still being crawled.
Both come from the same habit: reading robots.txt top to bottom like code. Crawlers don't read it that way. This guide shows how to test a robots.txt file the way Google actually applies it, with a real file you can copy, a quick script, and a free tester.
We built MyToolStudio, a set of free browser tools, and robots.txt questions come up a lot. Last time in this series we looked at decoding a JWT without pasting it into a random website. This one is for the SEO side of the team.
Why testing robots.txt matters
robots.txt controls crawling, not indexing. A wrong Disallow can stop Google from fetching pages you need, and a wrong Allow can let crawlers waste time on endless filter URLs.
A few facts from Google's own documentation that change how you test:
- Google generally caches robots.txt for up to 24 hours, so a fix is not seen instantly.
- Google ignores anything after the first 500 KiB of the file.
- If robots.txt returns a 4xx error (except 429), Google acts as if there are no restrictions at all.
- If it returns a 5xx error, Google stops crawling the site for the first 12 hours.
So testing is not only "is this URL allowed". It is also "can Google fetch the file, and what status code does it get".
The rule most testers skip: the longest match wins
Here is a small file for an online store:
User-agent: * Disallow: /shop/ Allow: /shop/products/ Disallow: /*?sort= Disallow: /*.pdf$ User-agent: GPTBot Disallow: / Sitemap: https://example.com/sitemap.xml Read top to bottom, /shop/products/blue-mug looks blocked, because Disallow: /shop/ comes first. But Google uses the most specific rule, based on the length of the rule path. Allow: /shop/products/ is longer than Disallow: /shop/, so the product page is allowed. When an Allow and a Disallow rule are equally specific, Google uses the least restrictive one, which is the Allow. The same logic is written into RFC 9309, the robots.txt standard.
Two more things in that file:
-
*matches any run of characters, soDisallow: /*?sort=blocks every URL with a?sort=parameter. -
$anchors the end of the URL.Disallow: /*.pdf$blocks/files/guide.pdfbut not/files/guide.pdf?v=2, because that URL doesn't end in.pdf.
And groups: a crawler follows only the one group that names it most specifically. GPTBot matches User-agent: GPTBot, so it ignores the * group completely and is blocked everywhere.
How to test robots.txt by hand
1. Check the file Google can actually fetch
Open https://yoursite.com/robots.txt in a browser, then check the status code from the command line:
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/robots.txt You want 200. A 403 from a firewall or a 503 from a busy server changes how Google treats the whole site. Note that a CDN or bot-protection rule may treat Google's IP addresses differently from your laptop, so a 200 here is a good sign, not proof.
2. Check what Google saw
In Search Console, the robots.txt report (under Settings) lists the robots.txt files Google found for the top 20 hosts on your site, when each was last crawled, and any warnings or errors. You can also request a recrawl after a fix. It only works for domain-level properties, so a URL-prefix property with a path won't show it.
3. Test the rules with a script (carefully)
Python ships with urllib.robotparser, which looks like the perfect quick check:
import urllib.robotparser as rp robots = open("robots.txt").read().splitlines() r = rp.RobotFileParser() r.parse(robots) tests = [ ("Googlebot", "/shop/products/blue-mug"), ("Googlebot", "/shop/cart"), ("Googlebot", "/blog/post?sort=new"), ("Googlebot", "/files/guide.pdf"), ("Googlebot", "/files/guide.pdf?v=2"), ("GPTBot", "/blog/"), ] for ua, path in tests: ok = r.can_fetch(ua, "https://example.com" + path) print(f"{ua:10} {path:28} {'allowed' if ok else 'BLOCKED'}") We ran this exact script on three Python versions with the file above. Python 3.13.18 matched Google's rules on all six URLs. Python 3.11.18 and 3.12.3 got three of the six wrong: they reported the product page as blocked (first match instead of longest match) and treated * and $ literally, so the ?sort= URL and the PDF came back as allowed.
The lesson: a script is only as good as its parser. If you script robots.txt checks, check your Python version first, or compare against a tester that follows Google's precedence rules.
Test robots.txt with a free tool
We built the robots.txt tester for exactly this. You can fetch a live file from any site or paste a draft you haven't uploaded yet, list up to 100 URLs or paths, and tick the crawlers you care about, from Googlebot and Bingbot to AI crawlers like GPTBot, ClaudeBot and PerplexityBot.
We pasted the file above, added the six paths and ticked Googlebot and GPTBot. Each result shows Allowed or Blocked plus the exact line that decided it:
/shop/products/blue-mug is allowed for Googlebot by Allow: /shop/products/ (line 3), /files/guide.pdf?v=2 shows "No rule matches", and GPTBot is blocked on every path by line 8. You can also download the results as CSV, which helps when you check a long list of URLs from a crawl.
If you are writing a new file, the robots.txt generator gives you a clean starting point, and since your Sitemap: line should point to a working file, run it through the XML sitemap validator too.
Common robots.txt mistakes
- Using Disallow to hide a page from Google. Disallow stops crawling, not indexing. A blocked URL can still appear in results if other pages link to it. Use
noindexon a page Google is allowed to crawl. - Blocking CSS and JavaScript. Google renders pages. If
/assets/is blocked, it may not see your layout or content. - Forgetting the trailing slash.
Disallow: /blogalso blocks/blog-tipsand/blogger.html. UseDisallow: /blog/if you mean the folder. - Expecting a
*group to cover every bot. A crawler with its own group ignores the*group, so repeat any shared rules inside that group. - Leaving staging rules in production. A
Disallow: /copied from a staging site is still one of the most painful mistakes to find. - Testing once and forgetting. Plugins, CDNs and migrations change robots.txt. Re-test after every big release.
FAQ
How do I test a robots.txt file?
Check that /robots.txt returns a 200 status, look at the robots.txt report in Search Console to see what Google fetched, then test your important URLs against the rules with a tester that uses the longest-match rule, such as our free robots.txt tester.
Does robots.txt stop a page from being indexed?
No. It stops crawling. A disallowed page can still be indexed from links, usually without a description. To keep a page out of results, allow crawling and add a noindex meta tag or header.
How long does Google take to see robots.txt changes?
Google generally caches robots.txt for up to 24 hours. After a fix, you can request a recrawl from the robots.txt report in Search Console.
Wrap-up
Test robots.txt the way crawlers read it: longest match wins, ties go to Allow, * and $ are patterns, and each bot follows only its own group. Check the status code, check what Google saw, and test real URLs, not just the file.
All our free SEO, developer and design tools are on the MyToolStudio tools page. No sign-up.
References: How Google interprets the robots.txt specification · RFC 9309: Robots Exclusion Protocol · robots.txt report, Search Console Help




