killakonny
killakonny
CDCloudflare Developers
Created by killakonny on 3/15/2024 in #general-help
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
4 replies