Does anyone know how to migrate this deprecated Page Rule to the new Redirect Rule?

Here’s a screenshot of my deprecated Page Rule URL Forwarding that I would like to migrate to the new Redirect Rule:

The following expression takes care of the second wildcard match $2, but not the first one $1:

concat("", http.request.uri.path)

Does anyone know how to sort out the first wildcard match $1?

Again, my current deprecated Page Rule works as expected. But I would like to migrate to the new Rule sooner than later.

Any help would be greatly appreciated. Thank you.

It’s worth mentioning with this migration it’s not so clear, they plan on adding proper wildcard support in the new rules before getting rid of Page Rules: Page rules are now deprecated without good replacements? - #4 by ncano, and ensuring no one is left without proper support/a smooth migration (which just isn’t the case as of the current moment with some more complex rules).

The “magic” you’re missing here is the substring function with a negative index. You always know how long your domain is, so you can use that to grab the subdomain.

Your example seems a bit… weird, but let’s go with it for now.

The page rule version of this does the following:

Notice how it’s grabbing test. from the subdomain and /hey from the path.

Direct Redirect Rule equivalent is:

concat("", "/", substring(, 0, -10), "welcome", http.request.uri.path)
// Where -10 is the character count of your original domain. 

The uri.path field already comes with the leading slash. That produces the exact same output as the Page Rule.

Still as I said above, you may want to wait until the better wildcard support is added. (and I agree, it’s a bit of a meh way to do a migration, with all the warnings and lights and then saying “actually for these cases you should wait”, but all we can do is provide feedback on it)


Thank you so much, Tyler! :slightly_smiling_face:

1 Like

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