Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

URL Wildcard Pattern Matching, Subdomains, and Include–Exclude Precedence

How asterisk URL patterns match hosts and paths in browsers and edge platforms, and which include or exclude rule wins when several apply.

Wildcard URL patterns—most often a single *—let you target many hosts, paths, branches, or files with one rule. The same symbol appears in Chrome extension match patterns, Cloudflare Workers routes, Page Rules, Cloudflare Access application paths, AI Search path filtering, and the web platform URLPattern API. Each system uses similar-looking syntax but different precedence, case rules, and limits. This page explains what * actually matches, how subdomain patterns differ, and how include and exclude lists are evaluated.

Match pattern structure: scheme, host, path, and where * is allowed

Section titled “Match pattern structure: scheme, host, path, and where * is allowed”

Chrome extensions express allowed URLs as a pattern with the shape <scheme>://<host>:<port>/<path>. The match patterns documentation states that the scheme must be http, https, *, or file; the host may be a hostname, *.example.com, or *; and the path uses * to match zero or more characters.

A match pattern is a URL with the following structure, used to specify a group of URLs:

<scheme>://<host>:<port>/<path>

— Google Chrome, Match patterns

For http, https, and ftp URLs, content setting patterns follow the same syntax but require the path to be exactly /* (not a narrower path wildcard). Content setting patterns may also include an explicit port; if omitted, all ports match.

The special pattern <all_urls> matches any URL with a permitted scheme. Top-level domain wildcards such as http://google.*/* are not supported, because they would match unintended hostnames:

You cannot use wildcard match patterns like http://google.*/* to match TLDs (like http://google.es and http://google.fr) due to the complexity of actually restricting such a match to only the desired domains.

— Google Chrome, Frequently asked questions

List each TLD explicitly (for example http://google.es/* and http://google.fr/*).

Host wildcards: *.example.com versus *example.com

Section titled “Host wildcards: *.example.com versus *example.com”

On Cloudflare Workers, hostname wildcards are easy to confuse. Routes documentation contrasts *example.com/ and *.example.com/:

Request URL *example.com/* *.example.com/*
https://example.com/ Matches Does not match
https://www.example.com/path Matches Matches
https://myexample.com/ Matches Does not match

Because * matches zero or more of any character (not just subdomains), *example.com matches any hostname ending in example.com. This includes myexample.com and not-example.com. To match only example.com and its subdomains, use two separate routes: example.com/* and *.example.com/*.

— Cloudflare, Routes

Chrome’s host rule is stricter: if * appears in the host, it must be the first character and must be followed by . or /—patterns like http://foo.*.bar/baz are invalid (match patterns).

Path wildcards: slashes, trailing stars, and query strings

Section titled “Path wildcards: slashes, trailing stars, and query strings”

In Cloudflare AI Search path filtering, micromatch-style rules treat * and ** differently:

Single * does not cross directories: Use ** to match across path separators. For example, docs/* matches docs/file.pdf but not docs/sub/file.pdf, while docs/** matches both.

— Cloudflare, Path filtering

For website sources, patterns must account for scheme and hostname—for example **/blog/**, not /blog/** alone (Website data source).

Cloudflare Pages and Workers build watch paths use a single * that does match across /, so docs/* includes nested files such as docs/guides/advanced/config.md.

Always check whether * is “within one segment” or “greedy across slashes” for the product you configure.

Trailing /*, path*, and known Worker route bugs

Section titled “Trailing /*, path*, and known Worker route bugs”

Page Rules wildcard matching notes:

example.com/foo/* does not match example.com/foo, but example.com/foo* does match.

Workers known issues show that example.com/images/* and example.com/images* do not behave like many expect—all listed URLs may route to the worker using the images* pattern without the slash before *.

Worker routes match the entire URL including the query string. Because patterns cannot embed ?foo=, terminate with * when queries should match:

Since route patterns may not contain query parameters, the only way to have a route pattern match URLs with query parameters is to terminate it with a wildcard, *.

— Cloudflare, Routes

Legacy rate limiting paths treat * as matching any sequence including empty; example.com/path and example.com/path/ differ except for the homepage (Request path).

Cloudflare Pages and static asset headers allow one splat per URL pattern: * greedily matches, and the capture is referenced as :splat.

Subdomain depth: one level versus multi-level

Section titled “Subdomain depth: one level versus multi-level”

Several products only wildcard one label at a time unless you add more patterns.

TLS: Advanced Certificate Manager wildcard coverage:

Wildcard certificates only cover one subdomain level: A certificate for *.example.com covers www.example.com and api.example.com but not api.staging.example.com.

— Cloudflare, Advanced certificates

Cloudflare Access application paths: *.example.com covers alpha.example.com but not the apex example.com or foo.bar.example.com. Empty path or example.com/* covers the apex and its paths but not alpha.example.com. At most one * between each dot in the subdomain and between each slash in the path.

DNS: Wildcard records use * only on the first label; subdomain.*.example.com treats * as literal (Wildcard DNS records). A *.example.com record is multi-level by default unless a more specific record exists.

Turnstile does not accept * in the hostname field; adding a hostname authorizes that host and its subdomains (Hostname management).

Case sensitivity: mismatches between products

Section titled “Case sensitivity: mismatches between products”
Context Case behavior
Cloudflare Page Rules URL Case-insensitive (Additional reference)
Worker route path Case-sensitive (/Images/* ≠ /images/*) (Routes)
Worker route host (routes on/after 15 Oct 2023) Case-insensitive
AI Search path filters Case-sensitive; /Blog/* ≠ /blog/post.html (Path filtering)
Rules language wildcard operator Case-insensitive; use strict wildcard for case-sensitive (Operators)
Chrome declarativeContent URL filters Case-sensitive (declarativeContent)

When migrating Page Rules to filter expressions, remember Page Rules often ignore scheme and query strings, while http.request.full_uri includes both—use http*:// and a trailing * when queries must not break matching.

When several patterns match: specificity and precedence

Section titled “When several patterns match: specificity and precedence”

Cloudflare Workers routes: the most specific pattern wins—for example www.example.com/* over *.example.com/*, and example.com/hello/* over example.com/* (Routes). A route with no Worker attached can block a broader pattern (example with cat.png).

Chrome content settings: the more specific pattern wins; tie-breaking order is hostname, then scheme, then port (contentSettings).

Declarative Net Request urlFilter: anchor domains with || and paths with ^ or / so tokens do not match inside query strings (Write good URL conditions).

Brave Search Goggles support site=, path patterns, and * in rules such as */api/*$boost (URL Targeting).

Include and exclude lists: evaluation order

Section titled “Include and exclude lists: evaluation order”

Many Cloudflare features evaluate excludes before includes.

Browser Run crawl (crawl endpoint):

excludePatterns has strictly higher priority. If a URL matches an exclude rule, it is skipped, regardless of whether it matches an include rule.

— Cloudflare, Crawl web content

AI Search path filtering (path filtering): exclude check, then include check, then index. With only excludes, everything except excluded paths is indexed; with only includes, only matching paths are indexed; with both, exclude wins first.

Pages preview branches (branch build controls): order is (1) Excludes, (2) Includes, (3) Skip—e.g. Include *, Exclude dependabot/* builds all branches except those under dependabot/.

Build watch paths (Pages, Workers): paths matching excludes are ignored first; remaining paths are checked against includes; any match triggers a build. Pushes with 0 file changes, 3000+ changes, or 20+ commits bypass matching and build anyway.

URLPattern standardizes routing-style syntax (based on path-to-regexp) for full URLs, not only pathnames—including wildcard hostnames for cases such as service worker fetch routing. Use test() or exec() to match; named groups capture segments. Omitting a property in the object constructor defaults to *; using baseURL treats unspecified parts as empty string, not wildcard—see Constructing the pattern. Cloudflare Workers runtime lists URLPattern API among supported web standards.

Chrome DevTools request conditions accept patterns such as *://example.com to throttle or block matching requests during debugging.

  1. Using *example.com when you only want the apex and real subdomains—suffix matching also hits myexample.com (Routes).
  2. Expecting *.example.com to cover the apex domain (Application paths).
  3. Using one * in a path filter when files live in nested folders—use ** where AI Search requires it (Path filtering).
  4. Assuming example.com/foo/* matches example.com/foo (Wildcard matching in Page Rules).
  5. Unanchored urlFilter values such as google.com matching query parameters (declarativeNetRequest).
  6. TLD wildcards in extension match patterns (FAQ).
  7. Treating Gateway or list URLs with and without a trailing / as distinct when deduplicating—they are treated as the same (HTTP policies, Lists).
  1. For extension rules, reproduce hosts and paths against the tables in Match patterns and URL filter syntax; load a test page and confirm behavior in the extension’s background/service worker logs.
  2. For Worker routing, compare your patterns to the *example.com versus *.example.com examples in Routes, including paths with query strings, and read Known issues if you use path/* versus path*.
  3. For include/exclude filters (AI Search, build watch paths, or crawl), list one URL that should match and one that should not, then confirm order: exclude first, then include, per Path filtering or Build watch paths.
  4. In Chrome DevTools, add a request condition with your wildcard pattern and verify which network requests are affected.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.