Wildcard matching and referencing
You can use the asterisk (*) in any URL segment to match certain patterns. For example,
example.com/t*st would match:
example.com/testexample.com/toastexample.com/trust
example.com/foo/* does not match example.com/foo but example.com/foo* does match.
Helpful tips
- To match both
httpandhttps,write example.com. Writing*example.comis unnecessary. - To match every page on a domain, write
example.com/*. Writingexample.comwill not work. - To match every page on a domain and its subdomains, write
*example.com/*. Writingexample.comwon’t 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.
Referencing wildcard matches
You can reference a matched wildcard later using the $X syntax, where X indicates the index of a glob pattern. As a result, $1 represents the first wildcard match, $2 represents the second wildcard match, and so on.
The $X syntax is especially useful with the Forwarding URL setting. For example, you could forward http://*.example.com/* to http://example.com/images/$1/$2.jpg.
This rule would match http://cloud.example.com/flare.jpg which ends up being forwarded to http://example.com/images/cloud/flare.jpg.
To add a $ character in the forwarding URL, escape it by adding a backslash \ in front like \$.