How to write this transform rule?

Does anyone know how to write a transform rule that would:

If the url path contains
/shop/ref/stringa
/shop/ref/stringb
/shop/ref/stringc
etc…

Then transform it into:

/shop?ref=stringa
/shop?ref=stringb
/shop?ref=stringc
etc…

The difficulty (for this novice) seems to be in grabbing the string (stringa, stringb, stringc, etc.) and doing a preg_replace

Hi there,

I think this will meet your requirements, let me know if it works as expected for you. I did some testing, and it looks good to me.

Hope this helps!

1 Like

Wonderful.

That did solve it.

Thank you!

It seems like to write this required knowledge of JS, regex, and Cloudflare’s own syntax. Definintely an accomplishment that you pulled it all together in that Rewrite string.

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