Redirect Rule error

enterprise

New member
I want to redirect local images to the R2 bucket.
When I used the provided formula I got this error:

'oncat("media.networkservices.stream", substring(http.request.uri.path, 19))' is not a valid value for target_url because could not parse filter value expression: Filter parsing error (1:1): oncat("media.networkservices.stream", substring(http.request.uri.path, 19)) ^^^^^ unknown identifier

Can you help me with this?
My normal url is "https://networkservices.stream/wp-content/uploads/2020/12/blue-vector-1.png"
It should redirect to: "https://media.networkservices.stream/2020/12/blue-vector-1.png"

Thank you
 
Last edited:
Are you missing the "c" in "concat"? You just have it showing "oncat" in your copy/paste. It also needs the https:// at the beginning of the R2 bucket hostname. The expression should look like this:

Code:
concat("https://media.networkservices.stream", substring(http.request.uri.path, 19))
 
oh. I guess the "c" was missing. Is there a way to test if the url is being replaced?
If the URL you gave before is valid, it looks like a redirect is happening, but not to the full URL. A request for this:

https://networkservices.stream/wp-content/uploads/2020/12/blue-vector-1.png

...is being redirected to this:

https://networkservices.stream

The fact that it's not even going to media.networkservices.stream, makes me think it's not an issue with your expression, but something else upstream in the network stack if doing it's own redirect.

Cloudlfare has a pretty good network trace tool to help figure out what service/step is doing something with the request. Go here:

Put in the original URL: https://networkservices.stream/wp-content/uploads/2020/12/blue-vector-1.png

That should give you some info about what Cloudflare services/rules the request is passing through and which is being applied.
 
Back
Top