Cloudflare has recently rolled out “Dynamic Redirects” feature under Rules section. This lets you geo redirect without using a Worker. I actually prefer this to using a Worker.
The caveat is using a Static redirect won’t preserve the path. For example, let’s say we have all Chinese countries set to go to
example.com/zh-CN/ directory. The static option works well for redirecting
example.com requests to
However, if the request is to
example.com/about/ it will still redirect this to only
example.com/zh-CN/ and not
example.com/zh-CN/about/ as the static option doesn’t preserve the path.
I see it is possible to switch to a dynamic rule that allows for an expression. Is it possible to use an expression to allow the redirect while preserving the path? If so, could anyone please help with what an example expression would look like? Thank you!