Wildcard matching in Page Rules

Last updated Apr 16, 2026 You can use the asterisk (*) in any URL segment to match certain patterns. For example, example.com/t*st would match:

  • example.com/test
  • example.com/toast
  • example.com/trust

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

Note

Consider alternative Rules options due to their enhanced configurability. Refer to the migration guide for details.

For more flexibility and customization, consider using Snippets.

Helpful tips

  • To match both http and https, write example.com. Writing *example.com is unnecessary.
  • To match every page on a domain, write example.com/*. Writing example.com will not work.
  • To match every page on a domain and its subdomains, write *example.com/*. Writing example.com 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://*.example.com/* to http://example.com/images/$1/$2.jpg.

This rule would match http://cloud.example.com/flare.jpg, which would be 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 \$.

Caution

Avoid creating a redirect where the domain points to itself as the destination. A domain that points to itself can cause an infinite redirect error, which makes your site inaccessible to visitors.

Was this helpful?

YesNo

On this page

Wildcard matching in Page Rules - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/#page","headline":"Wildcard matching in Page Rules","description":"How wildcard and pattern matching works in Page Rules URLs.","url":"https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/","inLanguage":"en","image":"https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/og.png?v=90a728dcb364c602","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Resolve billing and subscription issues with Page Rules. title: Troubleshoot Page Rules - Billing and subscription image: https://developers.cloudflare.com/rules/page-rules/troubleshooting/billing-and-subscription/og.png?v=95d1abcd283d706d


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/rules/llms.txt
Use this file to discover all available pages before exploring further.