How to Point Your Domain Hosted at Free Cloudflare to Another Hosting without Changing NameServers

THE PROBLEM: Free Cloudflare doesn’t support custom nameservers.

THE SOLUTION: Use cname flattening to point the domain to the right server

The process itself is pretty straightforward: You create a cname record for the apex domain and set an existing domain or sub-domain as its content, the keyword here is “existing domain or sub-domain”. You must point to an existing name that already exists somewhere else on the Internet. Let’s see some possible scenarios:

The Addon Domain Points to the Main Domain’s Root

If your hosting supports multiple domains only as aliases for your main one, the CNAME value must be the default domain you already use. e.g.

MAIN DOMAIN: example.com

NEW DOMAIN: newdomain.com

NEW DNS RECORD IN CLOUDFLARE:

  • Type: CNAME
  • Name: newdomain.com or at (@)
  • Content: example .com

The Addon Domain Points to a Different Folder than the Main Domain’s Root (AKA You can have multiple websites on the same hosting account)

The way your hosting manages this part may vary, but the overall idea is as follows: When you add the domain to your hosting, it gives you the option to use it for your document root (same as the case above) or to create a separate document root, you must pick the ‘separate document root’ option and the hosting will create a subdomain for the new document root based on your new domain + the main one. This new subdomain is the one we will use for CNAME flattening.

Please keep in mind the Add Domain feature in your cpanel doesn’t affect the settings on your Domain Registrar at all, and it only instructs your hosting about what to do with the requests with that name that come from your nameserver.

MAIN DOMAIN: example.com

NEW DOMAIN: newdomain.com

NEW SUBDOMAIN: newdomain.com.example .com

NEW DNS RECORD IN CLOUDFLARE:

  • Type: CNAME
  • Name: newdomain.com or at (@)
  • Content: newdomain.com.example.com

The way your hosting creates the new subdomain may vary, please ask your hosting support for details about it

TROUBLESHOOTING

Another record with the same name already exists: Please look for another record with the same name value i.e. newdomain .com. IT DOESN’T MATTER IF IT’S ANOTHER TYPE OF RECORD. Remove it and add your CNAME record again. A records with the domain as name value are a common way to point domains too, but CNAME flattening resolves the name faster, making your page speed faster.

This post can also be found on my LinkedIn https://www.linkedin.com/in/aguachilema/
Alvaro Guachilema