Help with Page Rule redirects for Subdomains

Hello! Hoping you can help :slight_smile:

​I need some assistance/guidance for redirecting ~300 subdomains to a different subdomain, using page rules. I’ve read through the community and docs, can’t seem to find an answer…

For example… needs to redirect to …

I thought we had this figured out, and set up the dns records, and a wildcard redirect in page rules… but the behavior is not as intended. When the page rule is turned on, it breaks the root domain… We only want the subdomains to redirect.

We have DNS entry of each subdomain, with the orange cloud. For example: 1 IN A

The Page Rule that has been setup is to match the URL: https://* and Forward to: http://$

Is there something different I should be doing for my URL match in the Page Rule? Is there another page rule I can add to prevent the root domain from being affected? Please help! :smiley:



You could try creating a couple of page rules for the root domain and place it before the wildcard page rule:

1 redirects from naked to www

Forward to:$1

2 for the www subdomain, with a setting just to make it not trigger the wildcard page rule

Setting: Automatic HTTPS Rewrites

3 the wildcard page rule. Since your subdomains may have more than one URL, you may want to change your rule slightly:

URL: **
Forward to: https://$$2

You don’t need to add the HTTP/S in the source URL, only in the target.

Awesome - thanks @cbrandt. We now have this sorted out and your advise was helpful.

I also needed on additional redirect to make all subdomains always use HTTPS because I needed to have the forwarding URL include HTTPS in the URL for Cloudflare to consider it a valid page rule.

So, my page rules are as such, which works!

Forward to:$1
Automatic HTTPs Rewrites: On
URL: **
Automatic HTTPs Rewrites: On
URL: https://**
Forward to: http://$
1 Like

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