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:
subdomain.domainA.com/path-example

They will be redirected to:
subdomain.domainB.com/path-example

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

Thanks!

The DNS for subdomain.domaina.com 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 *.domaina.com/*
Settings:
Forwarding URL - 301 redirect
Enter the value as https://$1.domainb.com/$2.

image

You can see this rule in action:

https://sub.Cloudflaretools.com/path/b

1 Like

Thanks a lot.

It works !

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