Change domain name. What changes do I need to make in Cloudflare?

Hi, I have an active website that I have Cloudflare Pro Plan on it (with a dedicated/advanced certificate), and I want to change the domain name of the website, let’s say, from old.com to new.com. I also want to redirect all URLs from old.com to new.com (example: old.com/page-2 to new.com). My problem is that I don’t understand the thing with nameservers/DNS records at all. Hopefully, you can help me.

For the record, I will keep the original host and only change the domain.

My concerns are:

Regarding Cloudflare settings

How do I do it without losing all the settings I made for the old.com and without losing the Pro Plan and the advanced certificate? Do I need to add a new website in Cloudflare or update the existing one?

If I need to update the existing one, do I need to change the website URL that is shown in the Cloudflare dashboard from old.com to new.com, or is it done automatically once I update the nameservers and DNS records?

Regarding nameservers/DNS records

  • From my understanding, first, I need to change the nameservers for new.com to Cloudflare, right?
  • Once I have done that, should I remove the Cloudflare nameservers from old.com, so it doesn’t interfere with the new domain name?
  • Do I need to change DNS records in Cloudflare or leave them as they are now? As they’re pointing to my host, I don’t think I should change anything but correct me if I’m wrong, please.
  • Some DNS records in Cloudflare have the old.com in the “Name” tab. Should I update them to new.com, or does it not matter?

Once I have the nameservers/DNS records set up and the hosting is now pointing to new.com, once I enter new.com should send me to the live website, right? Or is there anything else I should do?

Regarding redirects

OK, considering the new domain nameservers are now pointing to Cloudflare, and everything is OK, what’s the best practice to make the 301 redirects. I want to do a wildcard redirect, aka redirecting all URLs from old.com to the same path to new.com.

Should I do it in Cloudflare, or should I do it from cPanel or .htaccess file? What happens if I set the redirects in both Cloudflare and cPanel just to make sure it doesn’t skip any URL?

In short, add the new domain to your Cloudflare account. Update the settings on the new account as to your liking, then change the nameservers for the new domain to activate it on Cloudflare. (Subscribing to the Pro plan if you need Pro features.

When you are happy the new site is working, create a page rule to redirect all requests to your new website, and cancel the Pro plan on the old domain.

You need to add the new website. You cannot change an existing domain name.

You should not remove them as it appears you still want to use the old domain for redirects. They will not interfere with each other.

A forwarding page rule like this will do the trick:
https://*old.com/*https://new.com/$2

Everything matched by the second * on the source will be copied to $2 on the destination of the redirect. (In this example the first * will ensure that both old.com and www.old.com are matched). Make sure the Page rule is at the top of the list of page rules.

I’d do the redirects in Cloudflare only. In your use case no traffic should ever hit the origin, and I would delete everything to do with old.com from the origin. (I’d also replace the DNS records for old.com with dummy placeholder values to make it obvious what was happening when somebody looks at this in a few years.

1 Like

Hi, thanks so much for your support but I need to clarify this with you.

  1. So I have the OldDomain live on my OriginalHost.
  2. I create a new account in cPanel for the NewDomain to create a new separate directory for the NewDomain on the same host.
  3. I enter the directory folder for the NewDomain and copy all the WordPress files from the OldDomain.
  4. Copy the database from the OldDomain to NewDomain too.
  5. Now I’m updating the URL in wp-config to reflect the URL of the NewDomain.
  6. Next I add a new site in Cloudflare for the NewDomain.
  7. Change the nameservers of NewDomain to point to Cloudflare.
  8. Now both NewDomain and OldDomain should be live on the same host, with the exact same content, but no redirects, right?
  9. The only thing now is to build a 301-header for the OldDomain to redirect 1:1 to NewDomain via Cloudflare or cPanel, right?

Have I missed something?

Really appreciate all the help.

Items 1 through 5 are out of scope for support here. Having performed domain name changes on on WordPress sites, I would encourage you to dig deeper into the process, as there is usually more to it than just updating the site URL in the wpconfig.php.

The rest looks fine. For your redirects, you could use Bulk Redirects on Cloudflare, and retire the old domain on the origin server.

1 Like

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