The asterisk (*) only supported in Page rules, when others not?

One of the best features I found on Cloudflare is the dynamic redirecting, not in the Redirect Rules, but in the Page Rules, where it should be in Redirect Rules.

So, I really hope the Cloudflare team will support the asterisk in “Redirect Rules,” not just in Page Rules. I tried hard to achieve the same results of Page Rules in Redirect Rules, but it’s not possible. I attempted to use Workers to achieve the same thing, but the Workers are showing SLOW in redirection, way slower than Page Rules.

It is possible:

https://developers.cloudflare.com/rules/url-forwarding/single-redirects/examples/#redirect-all-requests-to-a-different-hostname

3 Likes

You have to leverage the fields and operators more, and custom expressions, but mostly everything is doable.

The way to do a simple redirect for everything is already linked above, more complex stuff is a bit harder though.

For example, Page Rules redirecting all subdomains might be something like
*example.com/*
$1example.com/$2

But in Redirect Rules its
Edit Expression → true
Formula: concat("https://", substring(http.host, 0, -12), "newsite.com", http.request.uri.path) // Where -12 is the character count of your original domain. This works on apex or subdomains

Way more messy but doable. I wouldn’t hold your breath for wildcards to come.All the new rules are powered by the ruleset engine, wireshark display like filters, tons of docs here: Rules language · Cloudflare Ruleset Engine docs

1 Like

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