2

I need the minimal DNS records to either point/redirect a domain at an existing web and email service. I am looking at some existing redirection DNS records and there seem to be many more than necessary.

All I need are the following

  • example.net -> example.com
  • mail.example.net -> mail.example.com
  • www.example.net -> www.example.com

I am not sure of A, AAAA, MX, PTR, TXT,CNAME etc that they have included which are strictly necessary for a basic set of records.

Are there wildcard records to just point the lot at an existing web and email service?

1

You don't do this in DNS, it is done in .htaccess (on an Apache server).

e.g.

RewriteEngine on
RewriteRule (.*) http://www.example.com/ [R=301,L]

We would possibly be able to help more if you told us what sort of server and if you use cpanel or another hosting panel.

If your hosting company isn't helpful, I suggest finding another, there is a huge choice.

2
  • That only redirects HTTP, it doesn't help with email.
    – Barmar
    Jul 26 '21 at 14:12
  • For simple cases like that, no need to use mod_rewrite at all, Apache has Redirect directives. Jul 26 '21 at 14:30
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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