How to achive dynamic redirect

How can I redirect
https://*.example.com/pages/*
to
https://example.com/$1/$2
using the new Dynamic Redirects rather than Page Rules?

Where is the issue here? The actual redirect section or the filter expression to target https://*.example.com/pages/*?

Previously I am using Page Rules to redirect all the incoming requests. Now I wish to change it to Dynamic Redirects. How can I do that?

What kind of Expression should I use for the target?

image

You haven’t replied to my question, the issue is on the When incoming requests match… or the Then… section?

edit saw your edit now.

1 Like

Then section.

Ok, I came up with a solution, which doesn’t actually work due to limitations on a feature.

I’ve already pinged the product’s PM, he might have some solutions or it will become a feature request. The management via * and $1 was very easy to do and understand, albeit very much limited.

Ok, it now works with a secondary solution. It’s using an undocumented function and it’s very much not as elegant nor as simple as Page Rules.

concat("https://example.com/", substring(http.host, 0, -12), "/", substring(http.request.uri.path, 7))

Substitute -12 with the length of your domain, that is the length of .example.com, dot included. Same goes with the 7, it’s the length of /pages/.

1 Like

Wish this feature will be made possible with Dynamic Redirects in an easy manner.

1 Like

Me too, me too. The feature’s PM agrees, though. So there is hope.

1 Like

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