Your robots.txt file is the single most powerful lever you have over how crawlers, including AI bots, interact with your website. Get it right and you control your AI visibility. Get it wrong and you can disappear from AI answers overnight.

In this guide you will learn how to use * and $ patterns correctly in robots.txt. We will keep it practical, with clear steps, visual breakdowns, and specific actions you can take today. The first step in any AI visibility project is to run a free AI crawler check on your website so you know exactly where you stand against the 196 bots we track across 8 categories.

Key Takeaways

  • robots.txt Wildcards and Pattern Matching Explained is a practical, repeatable process, not a one-time fix.
  • Most AI visibility problems trace back to access, not content.
  • You can verify every change with the free AI crawler check and the robots checker.
  • Document your approach so the whole team applies it consistently.
Anatomy of a robots.txt file with annotations An annotated robots.txt example. The User-agent line targets a specific bot such as GPTBot. Disallow blocks paths, Allow grants exceptions, the wildcard user-agent covers every other bot, and the Sitemap line points crawlers to your XML sitemap. # AI crawler rules User-agent: GPTBot Disallow: /private/ Allow: /blog/ User-agent: * Sitemap: /sitemap.xml Targets one bot by name Each bot reads only its own section Blocks specific paths Grants exceptions Allow overrides broader Disallow Wildcard = every other bot Helps crawlers find pages Always declare your sitemap
Anatomy of a robots.txt file: user-agent targeting, allow and disallow rules, and sitemap declaration.

How to Change robots.txt Without Breaking Anything

robots.txt failures are rarely subtle in effect and almost always subtle in appearance, so the sequence is built around proving each change before the next one.

5 Steps, in Order
1

Read the file that is actually served

Request robots.txt from the live domain rather than opening the copy in your repository or your CMS settings screen. Those three frequently disagree, and only one of them is what crawlers see.

2

Identify which rule matches which agent

Group rules by user-agent block and work out which block a given crawler will obey, remembering that the most specific matching block wins and that a crawler obeys exactly one. This is where most misdiagnosis happens.

3

Change one thing, in one block

Broad rewrites make attribution impossible when something breaks. Edit a single directive, note what you expect to change, and generate the replacement with a robots.txt builder rather than by hand.

4

Test the rule against real paths before publishing

Run the edited file through a robots checker with the specific URLs you care about, including at least one you intend to block and one you intend to allow. A rule that passes syntax checking can still match nothing.

5

Verify from outside, then record what you changed

Fetch the live file again and re-run an AI crawler access checker. Then write down the change and the reason, because the next person to debug this file will otherwise be guessing at your intent.

Why Wildcard Pattern Matching Is Harder Than It Looks

robots.txt supports only two special characters, an asterisk for any sequence and a dollar sign for end of URL, and neither is in the original specification. They are widely honoured extensions, and their behaviour is not what people familiar with regular expressions or shell globbing expect.

The consequence is that patterns fail silently in both directions. A pattern can match far more than intended because matching is a prefix operation, or match nothing because a dollar sign was placed where a query string follows. Neither failure produces an error, so the only way to know is to test against real URLs.

Four Ways Wildcard Pattern Matching Behaves Unexpectedly

Every pattern is anchored at the start and open at the end

Disallow: /private matches /private, /private/file, and also /privatedata, because the pattern is a prefix and there is no implicit boundary. Adding a trailing slash constrains it to the directory. Assuming an implied word boundary is the most common source of over-blocking, and the collateral damage is usually a legitimate path nobody thought to check.

The dollar sign is the only way to express ends with

Disallow: /*.pdf matches any URL containing .pdf anywhere, including /files/report.pdf?download=1 and /pdf-guides/intro.html. Disallow: /*.pdf$ matches only URLs that terminate in .pdf, which also means it stops matching the moment a query string is appended. Deciding which behaviour you want is a real decision and most files make it by accident.

Query strings are part of the path for matching purposes

Patterns are compared against the full path including the query, so a rule intended for a clean URL will not match the same page with tracking parameters attached, and a rule using a dollar sign will match neither. Sites with heavy parameter use need patterns written with the parameters in mind rather than the canonical form.

Case sensitivity applies to paths but not to user agents

Path patterns are matched case sensitively, so /Private and /private are different rules, while user-agent names are matched case insensitively. Mixing these up produces a file that appears to name the right crawler and blocks a path that does not exist. On a case-insensitive server this can also mean the intended path stays fully crawlable.

The four pillars of AI visibility Four pillars supporting AI visibility. Pillar 1 Access: AI crawlers can reach your pages. Pillar 2 Infrastructure: llms.txt, sitemap and HTTPS in place. Pillar 3 Structure: clear headings, FAQs and schema markup. Pillar 4 Authority: expertise signals and citations from trusted sources. AI VISIBILITY: read, trusted, and cited by AI engines 1 ACCESS Crawlers can reach your pages: robots.txt, WAF, no JS walls 2 INFRASTRUCTURE llms.txt, XML sitemap, HTTPS, clean canonical URLs 3 STRUCTURE Clear H2/H3 headings, FAQs, schema markup, quotable paragraphs 4 AUTHORITY E-E-A-T signals, author pages, mentions on trusted sources Work the pillars in order: authority means nothing if crawlers cannot access your pages in the first place.
The four pillars of AI visibility: access, infrastructure, structure, and authority.

Where Wildcard Pattern Matching Usually Goes Wrong

Writing a prefix pattern and reading it as an exact match

The classic case is Disallow: /admin, added to protect an admin area, which also blocks /administrator-guide and any other path sharing the prefix. The intended target is protected, so the change looks successful, and the collateral loss is a set of pages nobody thought to test. This is the reason to check what a pattern matches rather than only whether it matches the target.

The One Wildcard Pattern Matching Check That Settles It

The check that matters here: For each wildcard pattern in your file, list one URL you expect it to block and two you expect it to leave alone, then test all three. The second and third are where the surprises are.

Where to Go From Here

Wildcard Pattern Matching is one piece of a larger picture. The AI crawler directory documents every crawler we track with its operator, purpose and safety rating, and the batch URL checker audits many sites in one pass if you manage a portfolio.

Syntax errors in robots.txt fail silently, so validate before you publish. Use the robot checker, then confirm the result with an AI crawler access checker.

Your Wildcard Pattern Matching Action Checklist

Five concrete steps, specific to what this guide covered. Work through them in order, changing one thing at a time so you can tell which change produced the result.

  • Back up your current robots.txt before editing, so you can revert if a rule behaves unexpectedly.
  • Apply the pattern from this guide to a copy first, then diff it against the live file.
  • Run the robots.txt validator to confirm the syntax resolves the way you intend.
  • Check that no Disallow rule shadows a path you meant to allow, which is the most common silent failure.
  • Re-crawl after the change, because engines cache robots.txt and the effect is not instant.