How can multiple subdomain be redirected to only one specific subdomain using CloudFlare?

How can multiple subdomain be redirected to only one specific subdomain using CloudFlare? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the How can multiple subdomain be redirected to only one specific subdomain using CloudFlare? error on your web browser. Problem :


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

  • sub2.site.example/article

  • sub3.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


Solution :

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


We hope that this article has helped you resolve the redirects, subdomain, cloudflare error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=