How can multiple subdomain be redirected to only one specific subdomain using CloudFlare?
How can i redirect multiple subdomain to one specific subdomain using CloudFlare page rule.
Note: redirect without changing the URL path (only sub domain change)
For example:
sub1.site.example/articlesub2.site.example/articlesub3.site.example/article
into:
newsub.site.example/article
If any of the 3 examples URLs is typed in browser, it should automatically redirect to newsub.site.example
How can this be done using cloudflare page rule? Please help
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 Redirectnewsub.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 Redirectnewsub.site.example/$1
If the URL matches: sub2.site.example/*
The settings are: Forwarding URL, 301 Permanent Redirectnewsub.site.example/$1
If the URL matches: sub3.site.example/*
The settings are: Forwarding URL, 301 Permanent Redirectnewsub.site.example/$1
Comments
Post a Comment