: Forwarding non-www domain to other domain using DNS 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
Is it possible to forward firstdomain.com to seconddomain.com or seconddomain.com using purely DNS records?
I know how to forward 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.
More posts by @Sent6035632
3 Comments
Sorted by latest first Latest Oldest Best
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
Point the hostname to a server
The server should be configured to accept HTTP connections
The server should also be configured to understand HTTP connections for the source hostname
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:
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.
Use a DNS provider that offers you some kind of redirection service.
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 ^(.*)$ seconddomain.com ErrorLog logs/firstdomain.com-error_log
TransferLog logs/host.example.com-access_log
</VirtualHost>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.