Transform Rule not replacing URL correctly

Hi all!

I am trying to rewrite a called URL with transform rules, but it does not work out as expected. What I got is:

I call,quality=10/img/someimage.jpg

Now the transform rule should transform the called url to:,quality=10/

but what the transformation gives me is:,quality=10/https:/

As you can see in the injected url the second slash is missing, and thats why I get an invalid url error. My matching string is: (http.request.uri.path matches "/img/.") and (not (any(http.request.headers[“via”][ ] contains “image-resizing”))) and the rewrite to dynamic string is: regex_replace(http.request.uri.path, “(.)/img/(. )”, "${1}/${2}") Any ideas why the second slash is not transformed correctly? Do I have to escape the slashes in some way?

Thanks in advance

Hi @dennis.beyer have you tried implementing Page Rules instead?
Page Rules allows you to implement wildcards for URL Forwarding and it’s much easier than using Regex.

This is an example of what you are trying to achieve using Page Rules:


Thanks for the answer.
In the end when there is no better solution, this would be the solution i would have to go with.
But what I was trying to achieve is not having a redirect, because of SEO reasons.
Or would this redirect be handled internally in Cloudflare so Google, the end users etc would not notice it?

see above

I tried this now and as I assumed the redirect is happening also in the browser when calling the “masked” URL … but what I want to reach is that in no case anybody can see the attached in my URL.

So I guess in the end the solution has to be one (or more) transform rules. But unluckily I am not getting behind this, why the replacement of the image’s destination URL returns https:/ with only one slash instead of 2 slashes.