It isn't possible to use DNS alone to implement redirects. All that DNS can do is point a domain to a server. It is the job of the web server to issue the redirects. Even if you use a CNAME
record to point the domain to the same server as another domain, you still have to configure the server to redirect as opposed to showing the same content as the other domain or showing other content entirely.
You are correct that you probably don't need every type of DNS record. However if some are getting created automatically, they don't usually hurt anything, so I would just leave them. At the very least you are going to need:
- DNS
NS
records at your domain registrar pointing to your DNS host.
- DNS
A
records for example.net
and *.example.net
pointing to the IP address of the redirecting web server. (The wildcard record covers ALL subdomains, but it doesn't cover the bare domain. So you need the two records so that the bare domain works as well.)
If you want to support IPV6 with your redirects, you will also need corresponding AAAA
records pointing to the IPV6 address of the redirecting web server.
You could use a CNAME
record for *.example.net
rather than an A
record. However you MAY NOT use a CNAME
record for example.net
because CNAME
records are NOT ALLOWED at the domain apex. If you try to do so, some DNS editors will allow it, but it will break other things (like email sent to that domain.)
If you want email to this alternate domain to be delivered the same as it for the main domain, you will need MX
records pointing to your email server and you will need to configure the email server to accept that mail and deliver it to the example.com
mailboxes. Most email servers call this a "domain alias" or "secondary domain".
As for configuring a web server to issue the redirects, I now recommend using Cloudflare for redirecting alternate domains. They have a free service tier that can handle alternate domain redirects. Their redirects also automatically fully support HTTPS. It's a multi-step process to set up, but once set up it works perfectly. See complete instructions for setting up alternate domain redirects at Cloudflare.
If you don't want to use Cloudflare, then pointing the domain to your existing web server, adding an alternate domain to your account, setting up SSL certificates for it, and configuring that domain to redirect using .htaccess
as detailed by other answers is a fine solution too.