Dynamic Wildcard Redirect Rule

Hi Cloudflare Community,

Quick question on the new redirect rules, struggling to translate this simple page rule to a new redirect rule using expressions:

So redirect from /old-path/* to /new-path/*.

Any help would be greatly appreciated.


We are working on bringing wildcard support to the Ruleset Engine this year and making user experience straightforward when it comes to redirects.

For now, I can suggest expressing the same rule using substring and concat functions to replace old path with a new one:

Filter expression:

(starts_with(http.request.uri.path, "/old-path/"))

Dynamic URL redirect expression:

concat("/new-path/", substring(http.request.uri.path, 10))

where start byte value (10 in my example) is the length of the old path.

If you are on Business or Enterprise, you can also use regex_replace if you are more comfortable with regular expressions syntax. I’ve provided some examples here for reference.


Works a charm, thanks a bunch for the prompt response @ncano :raised_hands:


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.