How to setup URL redirect to keep sub-domain and path on Cloudflare?


Hello. Any suggestion on how to achieve the below setting? By DNS setting?

When visitor go to:

They will be redirected to:

So, basically the goal is to keep whatever sub-domain and whatever path while redirecting.



The DNS for will need to be in the DNS tab at Cloudflare (pointing to anything) and :orange:. You’ll need to add a record for each subdomain you want to redirect, as wildcard records can’t be :orange:.

Then you can create a Page rule for domaina at so:

Matching url **
Forwarding URL - 301 redirect
Enter the value as https://$$2.


You can see this rule in action:


Thanks a lot.

It works !


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