Cloudflare has the documentation about page rules here: https://support.cloudflare.com/hc/en-us/articles/218411427-Understanding-and-Configuring-Cloudflare-Page-Rules-Page-Rules-Tutorial-
You might be able to use a single page rule to do this, if you don't mind redirect any subdomain that starts with sub
. You could use two wildcards, one for number in the subdomain and the other for the URL path. The first wildcard becomes $1
and the second becomes $2
. Because you are discarding information about the subdomain, you would not use $1
in the resulting URL, but you would use the $2
to preserve the path:
If the URL matches: sub*.site.example/*
The settings are: Forwarding URL, 301 Permanent Redirect
newsub.site.example/$2
If your subdomains don't match a pattern, or if you have other subdomains that you want to keep that fit the pattern, you would need to use multiple page rules. With multiple page rules you only use one wildcard, so the path is $1
is the resulting URL. A free Cloudflare account only gets three page rules, so this would use up all of them.
If the URL matches: sub1.site.example/*
The settings are: Forwarding URL, 301 Permanent Redirect
newsub.site.example/$1
If the URL matches: sub2.site.example/*
The settings are: Forwarding URL, 301 Permanent Redirect
newsub.site.example/$1
If the URL matches: sub3.site.example/*
The settings are: Forwarding URL, 301 Permanent Redirect
newsub.site.example/$1
newsub
?newsub
subdomain?