Why You Can't Use a CNAME Record to Redirect Your Domain Make it Rain Paper

  • DNS, DNS Management, DNS Configuration, CNAME
  • 0

Overview

A common misconception is that a CNAME record can be used to redirect a domain. In fact, CNAME records cannot perform redirects. This article explains the differences between CNAMEs and actual redirects, and what to do if you need to forward a domain.

Pre-requirements

  • Access to DNS management tools (e.g., WHM, cPanel, external DNS panels)
  • Basic knowledge of DNS records and server configurations

Understanding CNAME Records

A CNAME (Canonical Name) record is used to alias one domain (e.g., domain-A.com) to another domain (e.g., domain-B.com). The CNAME record allows traffic sent to domain-A.com to resolve to the same IP address as domain-B.com.

Why CNAME Records Can't Perform Redirects

A CNAME record only affects DNS resolution and will not change the URL in a browser. A true redirect involves changing the URL a user sees, typically using one of the following methods:

  • Server-side code: Using languages like HTML, JavaScript, or PHP to implement a redirect.
  • Webserver configuration: Setting up a redirect via mod_rewrite (for Apache) or rewrite rules (for NGINX).

Steps to Set Up a Proper Redirect

1. Redirect Using .htaccess (Apache Web Server)

If you're using an Apache web server, you can add the following redirect rule to your .htaccess file:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain-A.com [NC]
RewriteRule ^(.*)$ http://domain-B.com/$1 [L,R=301]

This will perform a 301 (permanent) redirect from domain-A.com to domain-B.com.


Did this answer help?

« Back