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

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:
http://test.example.com/heyhttps://new-example.com/test.welcome/hey

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

Direct Redirect Rule equivalent is:

concat("https://new-example.com", "/", substring(http.host, 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)

3 Likes