Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudflare redirect everything from domain1.com to domain2.com

I would like to redirect all traffic from domain1.com (including all sub-domains) to index page of domain2.com using Cloudflare. Is it possible?
Furthermore, is it possible to not create any A records for domain1.com for this forwarding to work?

Thanks!

like image 901
Monty Chain Avatar asked Jul 31 '18 08:07

Monty Chain


People also ask

How do I redirect traffic from one website to another?

Under the Domain category, choose the Redirects menu. You'll see the Create a Redirect section. Here, you'll need to fill in which URL you want to Redirect and where you want it to Redirect To. Make sure your information is correct and choose the right connection protocol – HTTP or HTTPS.

How do I redirect a whole domain?

To 301 Redirect an Entire Domain:Replace http://www.new-domain.com/ with the URL that you would like your site to redirect to. Be sure to add a blank line at the end of your . htaccess document.


1 Answers

Ok, it seems I fugured it out myself and this solution works:

  • Create a Page Rule where every URL that matches *domain1.com/* is 301-redirected to https://domain2.com
  • Add A record where name is domain1.com and it points to 1.1.1.1
  • Add CNAME record where name is * which is an alias of domain1.com

Then I had to wait a couple of minutes for it all to take effect.

like image 153
Monty Chain Avatar answered Sep 30 '22 07:09

Monty Chain