CNAME

Definition

CNAME, or Canonical Name, is a type of DNS record that maps an alias name to the true or canonical domain name. This allows multiple domain names to point to the same IP address without needing multiple A records. For instance, if you have a website accessible via both www.example.com and example.com, a CNAME record can point www.example.com to example.com, ensuring they both resolve to the same site. This is particularly useful for managing domains and ensuring consistency across multiple URLs.

Why it matters

CNAME records are essential for maintaining a clean and efficient domain structure. They simplify the management of domain names by allowing administrators to create aliases that redirect to a primary domain. This not only helps in keeping the DNS records organised but also enhances user experience by ensuring that all variations of a domain lead to the same content. Additionally, CNAME records can be beneficial for setting up subdomains, facilitating easier updates and maintenance of web services.

Example in VCA

In the context of Vibe Code Academy (VCA), a CNAME record might be used to redirect students from a promotional subdomain, such as learn.vibecodeacademy.com, to the main site at vibecodeacademy.com. By setting up a CNAME record, VCA ensures that any traffic directed to the subdomain seamlessly leads users to the primary site, providing a consistent experience and maintaining brand integrity.

Another Real World Example

Consider an e-commerce website that operates under multiple domain names, such as shop.example.com and example-shop.com. By using CNAME records, the website can point both domain names to the same server, allowing customers to access the same online store regardless of which URL they enter. This not only simplifies the management of the website but also helps in consolidating traffic and improving search engine rankings by avoiding duplicate content issues.

Common mistakes

  • One common mistake is using a CNAME record for the root domain, which is not allowed by DNS standards. CNAME records should only be used for subdomains.
  • Another error is failing to update CNAME records when changing the primary domain, which can lead to broken links and loss of traffic.
  • Some users mistakenly believe that CNAME records can point to IP addresses, but they can only point to other domain names.
  • It's also a mistake to create circular references with CNAME records, where two records point to each other, causing resolution failures.

Related terms

  • <a href="/glossary/dns" data-glossary="dns" class="glossary-term">dns</a>
  • <a href="/glossary/domains" data-glossary="domains" class="glossary-term">domains</a>
  • <a href="/glossary/a-records" data-glossary="a-records" class="glossary-term">a-records</a>

Cookie choices

We use cookies to improve your experience

We use essential technologies to keep Vibe Code Academy secure and working properly. With your permission, we’d also like to use optional analytics and similar technologies to understand how the platform is used, reduce friction, and improve the experience over time.