Redirect multiple subdomain to one subdomain using page rule?

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.com/article

sub2.site.com/article

sub3.site.com/article

into:

sub4.site.com/article

If any of the 3 examples url is type in brower, the should automatically redirect to sub4.site.com

How can this be done using cloudflare page rule? Please help

Hi @nicolashellene,

Do you want to do this for all subdomains with a DNS rewcord or just specific ones? If you want this for some specific subdomains, you will have to use separate rules (unless there is a pattern to match them) as Page Rules don’t support Regular Expressions, only basic wildcards.

1 Like

I have 4 subdomain

  1. ww1.vikingheroes.cc
  2. ww2.vikingheroes.cc
  3. ww3.vikingheroes.cc
    and
    ww4.vikingheroes.cc

I want all the 3 first subdomain to redirect to

ww4.vikingheroes.cc

keeping the path

I’m not sure you can do that without individual rules for each, given that there isn’t really a pattern to match without matching other hostnames as well.

1 Like

Is there any javascript code or cloudflare worker solution about this :thinking:

Yes, there’s a bulk redirect template here:
https://developers.cloudflare.com/workers/examples/bulk-redirects

2 Likes

Please help me how can i use this bulk code, am very new about using cloudflare worker

I surf on YouTube but nothing

Can you provide me a full tutorial please legend :pray::pray::sob::sob:

I assumed since you asked for this that you knew how Workers works.

I can only really refer you to the docs here:
https://developers.cloudflare.com/workers

You don’t need to install anything, but can enable Workers on your account, paste and modify the code. You may want to get a developer to help with this if you’re unsure.

1 Like

Ok sir​:+1::star:

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