Cloudflare Docs
Edit this page on GitHub
Set theme to dark (⇧+D)

Wildcard matching and referencing

You can use the asterisk (*) in any URL segment to match certain patterns. For example,*st would match:

  •* does not match, but* does match.

​​ Helpful tips

  • To match both http and https, write Writing * is unnecessary.
  • To match every page on a domain, write*. Writing will not work.
  • To match every page on a domain and its subdomains, write **. Writing will not work.
  • A wildcard (*) in a page rule URL will match even if no characters are present and may include any part of the URL, including the query string.

​​ Reference wildcard matches

You can reference a matched wildcard later using the $<X> syntax, where <X> indicates the index of a glob pattern. For example, $1 represents the first wildcard match and $2 represents the second wildcard match.

The $<X> syntax is especially useful with the Forwarding URL setting. For example, you could forward http://** to$1/$2.jpg.

This rule would match, which would be forwarded to

To add a $ character in the forwarding URL, escape it by adding a backslash \ in front like \$.