Setup subdomain if the primary domain is forwarded?

Is it possible to use cloudflare with a subdomain of a domain that is forwarded?

We are consolidating 2 sites.

One site will be forwarded to the other site.

However, we still want to setup subdomains for vanity urls etc. as it’s used in a podcast. I know we can use the wordpress htcaccess files for the existing shortened urls we have setup in the wordpress site.

My question is can I use Cloudflare to manage the DNS etc. for the forwarded domain… and then also use cloudflare for the subdomains that we will setup? I think we would do this via page rules?

Example:

test.com forwards to test2. com

Want to use subdomains for test.com
/vanityurl1
/vanityurl2

Can we / should we do this in cloudflare via page rules?

Thanks!

Hi @pam,

I am not sure exactly what you want to achieve here. Do you want the main domain to be redirected and sub.test2.com to redirect to test.com/sub?

This would be possible with page rules, but perhaps you can clarify what you are after.

You do not appear to be talking about subdomains, but URLs.

You would need three Page Rules to achieve what you want, I’m assuming the whole test.com domain just becomes an originless redirect configuration. You would need a DNS entry for test.com, and if there is no Origin I use an AAAA record with value :: and set to :orange:.

Only one Page Rule will trigger per URL, so put your most specific Page Rules at the top, and the catchall at the bottom.

Rule 1: test.com/vanityurl1 --> https://example.com/
Rule 2: test.com/vanityurl2 --> https://example.net/
Rule 3: test.com/* --> https://test2.com/

You can also do this easily in a worker, there is a template in the gallery you could copy. I’d base the decision on how many requests you will see and how many Page Rules you will need. You get some page rules and workers for free, and after that there is a relatively small cost.

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