Is it possible to forward firstdomain.com to www.seconddomain.com or seconddomain.com using purely DNS records?

I know how to forward www.firstdomain.com to seconddomain.com (using a CNAME).

What I am trying to do is move my site from one domain to another (new) one, and not break all the links that use the old domain name.

I can't do a 301 redirect as it's hosted on GitHub Pages and I don't have access to the web server.


3 Answers 3


I eventually gave in and solved this with a Apache config redirect (although I wanted to do it with pure DNS it looks like this is not possible...)

<VirtualHost *:80>
DocumentRoot /www/html/firstdomain.com
ServerName firstdomain.com
RedirectMatch 301 ^(.*)$ http://seconddomain.com$1
ErrorLog logs/firstdomain.com-error_log
TransferLog logs/host.example.com-access_log

What's wrong with a simple CNAME DNS entry?

CNAME redirect

  • What's wrong with it is that, as far as browsers and search engines are concerned, those would be two completely different domains with (assuming no funny webserver tricks) the same content. Of course, you can first use a DNS CNAME to make your old domain an alias for your new one, and then configure the webserver at your new domain to HTTP 301 redirect any requests for URLs on your old domain to the new one. Apr 4, 2013 at 14:56

No, it's not possible to achieve this using DNS only. DNS have no notion of redirect and there are a variety of reasons. Probably the most important, the redirect is essentially a part of the HTTP protocol and it's not necessarily related to DNS records.

You could potentially issue a redirect connecting directly to an IP or, vice-versa, a redirect concept would not make sense at all for a TXT record or even for a A record where the target server accepts only ssh connections (or any other protocol rather than HTTP(s)).

In order to achieve a redirect you need to

  1. Point the hostname to a server
  2. The server should be configured to accept HTTP connections
  3. The server should also be configured to understand HTTP connections for the source hostname
  4. and redirect the client via HTTP to the target hostname

The CNAME or A record would only cover the step 1, but in order to cover the others you also need a server that handles the HTTP redirect (because as explained this is part of the HTTP protocol and not currently covered in the DNS protocol)

There are a few possible solutions:

  1. Point the old domain to a custom server/site where you handle the redirection. You can easily accomplish it for free, for example with a simple app on Heroku.
  2. Use a DNS provider that offers you some kind of redirection service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.