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 (likehttp://google.esandhttp://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.commatches any hostname ending inexample.com. This includesmyexample.comandnot-example.com. To match onlyexample.comand 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”One * and path segments
Section titled “One * and path segments”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/*matchesdocs/file.pdfbut notdocs/sub/file.pdf, whiledocs/**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 matchexample.com/foo, butexample.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).
Splats in header routes
Section titled “Splats in header routes”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.comcoverswww.example.comandapi.example.combut notapi.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):
excludePatternshas 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 on the web platform
Section titled “URLPattern on the web platform”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.
Common mistakes
Section titled “Common mistakes”- Using
*example.comwhen you only want the apex and real subdomains—suffix matching also hitsmyexample.com(Routes). - Expecting
*.example.comto cover the apex domain (Application paths). - Using one
*in a path filter when files live in nested folders—use**where AI Search requires it (Path filtering). - Assuming
example.com/foo/*matchesexample.com/foo(Wildcard matching in Page Rules). - Unanchored
urlFiltervalues such asgoogle.commatching query parameters (declarativeNetRequest). - TLD wildcards in extension match patterns (FAQ).
- Treating Gateway or list URLs with and without a trailing
/as distinct when deduplicating—they are treated as the same (HTTP policies, Lists).
How to check this on your site
Section titled “How to check this on your site”- 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.
- For Worker routing, compare your patterns to the
*example.comversus*.example.comexamples in Routes, including paths with query strings, and read Known issues if you usepath/*versuspath*. - 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.
- In Chrome DevTools, add a request condition with your wildcard pattern and verify which network requests are affected.
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”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.