Redirect the url to R2 url

I have my static assets served via

https://www.mysite.com/uploads/abc.png

now i have uploaded my static assets to R2 storage and mapped to domain

https://cdn.newsite.com/site1/uploads/abc.png and i can access this url

Now i want to create a rewrite rule so that if anyone try to access

https://www.mysite.com/uploads/abc.png then it gets rewritten to

https://cdn.newsite.com/mysite/uplaods/abc.png

I have created a redirect rule which is working fine but i want to create a rewrite rule so that user dont know if its getting redirected to new url.

If i got go to rewrite rule page then i cant see any setting to reqwrite the host

Unless you’re on an Enterprise plan, you can’t do host overrides (change the hostname behind the scenes).

You would have to use a Worker, like this example:

1 Like

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