How can I rewrite URL according to the sub domains

I have read the documents, but the dashboard only provide URI and query in rewrite part, I can’t use the whole URL or hostname as parameters.

In a word, I hope to rewrite URL according to the sub domains.

Examples:

How can I rewrite such URLs?

Hi,

You can use the function substring() to replace parts of the dynamic fields that represent your hostname (http.host) and the path (http.request.uri.path) to achieve what you want. You can adapt from the example below:

2 Likes

It works! Thanks for your help.
Maybe we could add these function into documents as tips?

1 Like

I forgot to mention that the substring() function has been documented since that post: Functions reference · Cloudflare Ruleset Engine docs

1 Like

Probably I didn’t read documents carefully enough…
In short, thanks for your timely reply!
Now, this topic can be closed.

1 Like