What is a CNAME Record?

Last Updated on January 2, 2023 by 8 Comments

Editorial Note: We may earn a commission when you visit links on our website.
What is a CNAME Record?
Blog / WordPress / What is a CNAME Record?
Play Button

We’ve previously talked about how the Domain Name System (DNS) works, but this isn’t the whole picture. There are lots of additional cogs that make up the wheel, and so far we haven’t discussed some of the most common elements, such as CNAME records.

For this article, we’ll answer the question of what a CNAME record is, and show you several variants that you can use. Then we’ll talk about the limitations you’ll experience, and finally show you how to add them for your domain.

Let’s get to it!

Subscribe To Our Youtube Channel

What Is a CNAME Record?

At its core, the DNS works by mapping domain names to specific IP addresses. When you type a URL in your browser, it looks up the corresponding IP address through the DNS and leads you to the website you want to visit.

However, this is just one type of record the DNS uses. With CNAME records, you can map URLs as aliases to your canonical domain. This means if the IP address mapped to that canonical domain changes, your CNAME records will still work because they point to the root domain.

To offer a real-world example, let’s say you have these three URLs:

  1. yourwebsite.com
  2. www.yourwebsite.com
  3. yourwebsite.io

URL number one would be your site’s canonical domain, which points towards your site’s IP address. In practice, you’d need to set up a CNAME record that redirects www.yourwebsite.com visitors towards yourwebsite.com.

At the same time, we also have the same name registered using a different Top-Level Domain (TLD). This means you’d want to create a second record that redirects address three towards number one. All of that usually happens through your domain registrar or whichever service you use to manage the URLs that you “own”.

2 Examples of CNAME Records

In fact, CNAME entries come in many shapes and sizes. However, in most cases you’ll only need to set up one CNAME record for a new website – typified by the www example we just mentioned.

In a later section, we’re going to show you how to set up a similar record through your registrar. First, let’s go over three more examples in closer detail.

1. Setting Up Separate Hostnames for Services Such as File Transfer Protocol (FTP) or Email

If you want to access your website via FTP using a domain such as ftp.yourwebsite.com, you’ll need to set up a corresponding FTP CNAME record:

Setting up an FTP CNAME record.

This same approach applies to CNAME records for additional services that you use, such as email. Here, you’d want to set a “hostname” such as “mail” instead:

Creating a mail CNAME record.

Those records would correspond to the following two URLs:

  1. ftp.yourdomain.com
  2. mail.yourdomain.com

With most registrars, you can either enter the full hostname (those two URLs you see above) or an abbreviation such as wwwftp, and mail.

2. Pointing Addresses With Different TLDs Towards a “Main” Domain

In some cases, it pays off to register the same domain name using different TLDs. For example, you can set up a CNAME record for yourdomain.org that points towards yourdomain.com. Here’s how the record would look:

Configuring a new CNAME record.

It’s important to understand that you need to add this type of CNAME record to the domain you want to point towards a different URL. In other words, you can’t point a root level domain towards another using a CNAME record. Root domains, such as yourdomain.com need to be mapped towards an IP address.

Using this same approach, you can map entirely different domains to a root URL. Let’s go over how the mapping process works, so you know where to start.

How to Add CNAME Records For Your Domain

Adding new CNAME records works largely the same with most registrars, although the interface that each one uses might be different. To show you how this works, we’re going to set up a basic record to point a www URL towards its canonical domain. For starters, you’ll want to open your domain’s settings through your registrar.

For example, if you’re using Namecheap, the registrar includes an Advanced DNS tab for each domain you own. Within the tab, you can add multiple types of records (there are more options beyond CNAME!).

In the example below, you can see an “A” record. This is a type of record that maps your canonical domain towards your site’s IP address.

An example of an A record.

To add a record, you’d need to click on ADD NEW RECORD and select CNAME Record under Record Type:

Adding a new CNAME record.

Under Host you need to enter the www prefix for this particular example. Now add your website’s canonical domain under Target:

Pointing a www URL towards a canonical URL.

Finally, there’s one last setting called TTL. This acronym stands for “Time to Live” and it tells your nameservers how often they should update your DNS records. As you might know, DNS records take some time to “propagate” and become accessible globally. The lower your TTL time is, the shorter the wait should be.

In most cases, we recommend leaving this setting to Automatic as DNS records usually propagate fast enough. For now, save your new record, which should appear under its A sibling:

A and CNAME records.

Keep in mind that you can set up multiple CNAME records depending on your needs. In the previous section, we explored multiple options, and all of them can be set up concurrently.

What you can’t do is set up records that direct the same domain towards different canonical URLs. This means you couldn’t set up two records pointing www.yourdomain.com towards yourdomain.com and alternatedomain.com. If you’re setting up a new website, most times you’ll only need to create two records for everything to work. Those would be one A and one CNAME record.

Conclusion

CNAME records are a core component of the DNS. If you need to point domains towards one another (instead of towards an IP address), you’ll need to use CNAME records.

There are several uses for CNAME records, but two of the most common uses include:

  1. Setting up separate hostnames for services such as FTP or email.
  2. Pointing addresses with different TLDs towards a “main” domain.

Do you have any questions about how to use CNAME records? Let’s talk about them in the comment section below!

Article thumbnail image by DiA99 / shutterstock.com

Divi

Want To Build Better WordPress Websites? Start Here! 👇

Take the first step towards a better website.

Get Started
Divi
Premade Layouts

Check Out These Related Posts

WordPress Twenty Twenty-Five Review: 6.7 Features Worth It?

WordPress Twenty Twenty-Five Review: 6.7 Features Worth It?

Updated on December 9, 2024 in WordPress

WordPress recently launched its new default theme, Twenty Twenty-Five, along with WordPress 6.7. With new features and customization options, it offers more flexibility than the Twenty Twenty-Four WordPress theme. But is it worth making the switch? We put the new theme to the test and compiled this...

View Full Post
WordPress Security Guide for Busy Freelancers (2024)

WordPress Security Guide for Busy Freelancers (2024)

Posted on November 22, 2024 in WordPress

Though WordPress is built to be secure, it’s not entirely safe. It requires regular maintenance, and your responsibility increases even more when you manage your clients’ WordPress. This WordPress security guide lists effective set-it-and-forget-it ways for freelancers and agencies to...

View Full Post

8 Comments

  1. I have a question – I am changing my hosting from blogspot to blue host, so can I keep the same CNAME in the domain DNS settings or delete it..

    • Hi Patrika! I would contact BlueHost support and ask if there’s anything you need to do here. That way you know you’ll be getting an answer tailored to the platforms you’re working with.

  2. As a web host, I suggest that using a CNAME record for mail.example.com might end up leading to confusion.

    It is not at all uncommon to have DNS hosting plus email at one service and a website at another e.g. Squarespace, that doesn’t provide email. In this case the A record and MX records need to be different. The MX will need to point to (for example) mail.example.com and in turn that will need an A Record, not a CNAME.

    While I understand this blog is targetted at WordPress users the information is useful for everyone and should take them into account.

    • Thanks for your insight, Steve!

  3. Thanks for the article. Could you write one that goes through every single step in excruciating detail for separating the mail to go to gmail.com, outlook.com, and a couple more of the most popular business mail providers? The one I saw earlier didn’t go into how to set the whole thing up on a particular service.

    • Glad you liked the article! Thanks for your suggestion – it would be an interesting post to write. I’ll pass it along.

  4. Can I use Cname recotds to map domains to a subdomain? This question is in regards to setting up a WordPress multi-site.

    • Yes, Clay, you absolutely can use CNAME records for subdomain mapping! If you do a quick Google search, there are many tutorials for this available.

Leave A Reply

Comments are reviewed and must adhere to our comments policy.

Get Started With Divi