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 https://mysampledomain.com/images/width=1000,quality=10/img/someimage.jpg Now the transform rule should transform the called url to: https://mysampledomain.com/images/width=1000,quality=10/https://anotherdomain.com/media/image/someimage.jpg but what the transformation gives me is: https://mysampledomain.com/images/width=1000,quality=10/https:/anotherdomain.com/media/image/someimage.jpg 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}/https://anotherdomain.com/media/image/${2}") Any ideas why the second slash is not transformed correctly? Do I have to escape the slashes in some way? Thanks in advance
3 Replies
killakonny
killakonnyOP10mo ago
nobody has an idea?
Cyb3r-Jak3
Cyb3r-Jak310mo ago
I don’t believe transform allows you to change the host. You’d probably have to redirect instead
killakonny
killakonnyOP10mo ago
but I'm not trying to transform the host as it is but the host that comes as a parameter from where the image should be loaded as it is given here: https://developers.cloudflare.com/images/transform-images/transform-via-url/
Cloudflare Docs
Transform via URL · Cloudflare Image Optimization docs
You can convert and resize images by requesting them via a specially-formatted URL. This way you do not need to write any code, only change HTML …
Want results from more Discord servers?
Add your server