How to Properly Configure a CNAME Record to Redirect a Subdomain to an External Website


7 views

CNAME (Canonical Name) records are DNS records used to alias one domain name to another. They are commonly used to point subdomains to external services or websites. However, there are some important technical considerations when setting them up.

In your case, you're trying to point keep.mydomain.com to keep.google.com, but encountering DNS resolution errors. The issue likely stems from how you've configured the CNAME record value.

Here's what's wrong with your current configuration:

Name: keep.mydomain.com
Type: CNAME
Value: https://keep.google.com/  // This is incorrect
TTL: 300ms

For a CNAME record, the value should be just the target domain name without the protocol (https://) or trailing slash. Here's the correct format:

Name: keep.mydomain.com
Type: CNAME
Value: keep.google.com  // Correct format
TTL: 300

1. Protocol Handling: CNAMEs only handle DNS resolution, not HTTP/HTTPS protocols. Users will need to type the full URL (http://keep.mydomain.com) or you'll need server-side redirects.

2. SSL Certificates: If you want HTTPS to work, you'll need a valid SSL certificate for keep.mydomain.com.

3. DNS Propagation: After making changes, allow time for DNS propagation (typically up to 48 hours, though your 300ms TTL should help).

If you need more control over the redirection (like changing HTTP to HTTPS), consider these alternatives:

Option 1: Web Server Redirect

// Apache .htaccess example
RewriteEngine On
RewriteCond %{HTTP_HOST} ^keep\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://keep.google.com/$1 [R=301,L]

Option 2: Cloud-based Redirect

Many DNS providers offer URL forwarding services that can handle the redirect at the DNS level.

Use these commands to verify your DNS configuration:

// Command line examples
dig keep.mydomain.com CNAME
nslookup -type=CNAME keep.mydomain.com

Remember that CNAME records can't coexist with other record types for the same subdomain. Ensure you don't have conflicting MX, TXT, or A records for keep.mydomain.com.


When attempting to redirect a subdomain like keep.mydomain.com to an external service (e.g., keep.google.com), many developers encounter the frustrating ERR_NAME_NOT_RESOLVED error. The root cause often lies in DNS record formatting rather than CNAME functionality itself.

Your current configuration likely has two critical issues:


# Incorrect format (what you might have)
keep.mydomain.com.  300  IN  CNAME  https://keep.google.com/

# Correct format (what actually works)
keep.mydomain.com.  300  IN  CNAME  keep.google.com.

Notice the key differences:

  • Remove protocol (https://) from the target
  • Include the trailing dot for FQDN
  • Never include path segments

Use dig or nslookup to test your configuration:


dig CNAME keep.mydomain.com
# Expected output should show:
# keep.mydomain.com. 300 IN CNAME keep.google.com.

For true HTTP redirects (status code 301/302), consider these alternatives:


# Nginx configuration example
server {
    listen 80;
    server_name keep.mydomain.com;
    return 301 https://keep.google.com$request_uri;
}

# Apache .htaccess alternative
RewriteEngine On
RewriteCond %{HTTP_HOST} ^keep\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://keep.google.com/$1 [R=301,L]

Remember these technical constraints:

  • CNAME cannot coexist with other record types for the same subdomain
  • Some registrars require "@" notation for root domains
  • Cloud providers often need verification records
  1. Wait for DNS propagation (up to 48 hours)
  2. Clear local DNS cache (ipconfig /flushdns or sudo dscacheutil -flushcache)
  3. Verify with multiple DNS servers (Google's 8.8.8.8, Cloudflare's 1.1.1.1)