Regex in page rule url OR multiple rule urls can use the same settings

The lack of Regex support, forces you to create multiple Page Rules that do the same thing, but for different paths. I don’t want to get too general, by stepping up a directory either. I assume Regex is not supported because you want people to use up their page rule allotment, however when you can use up to 100 page rules, this gets out of hand. If you don’t want to support Regex, than at least allow multiple Page Rules to use the same setting, so I don’t have to duplicate the settings across multiple rules.

4 Likes

Without regex (or any way to exclude something), it is impossible to cleanly apply a page rule to match example.com/* except example.com/foo/* (for example, redirecting everyone visiting example.com somewhere except those properly visiting example.com/foo/bar). You can apply one rule to example.com/foo/* and another with lower precedence that matches example.com/*, but the higher-precedence rule exists with no purpose except catching it from reaching the lower precedence rule, and it is not possible to add a page rule without an action. So you must apply some random “no-op” action and hope it doesn’t have any adverse side-effects.

1 Like

This might be something you could accomplish with workers. Cloudflare has not shown any plans of implementing regex in page rules, likely for performance reasons.

1 Like

Writing custom JavaScript to run at request time is huge overkill to simply make the great idea that is Page Rules slightly more capable and less cumbersome. And if the Page Rules service is more capable, that means people would likely use it more often and pay for extra page rules. Hopefully by :heart:ing this thread Cloudflare may eventually add it.

3 Likes

Huge agreement here - it would be very nice to be able to match against multiple uri’s…
example.com/(fee|fi|foo|fum)? and so forth…

You can do this on one of the competitor platforms (who shall remain nameless), or you might look into an open-source http caching utility like Varnish-Cache which handles those kind of redirects/vcl logic very well.

1 Like