Skip to main content
2 of 2
Exemplified domains according to RFC2606 and to match edited question.
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

In order to do a 301 redirect, there needs to be a server at the specified location to reply to the browser's request for content with a location like:

HTTP/1.1 301 Moved Permanently
Location: http://domainb.example

This is necessary because the server has to reply to the browser over HTTP with a response. This kind of redirect cannot be done with DNS because that is not the purpose of DNS.

You might consider setting a CNAME record for DomainA.example with DomainB.example as the value. Your DNS zone might look something like:

NAME                    TYPE   VALUE
--------------------------------------------------
www.domaina.example.    CNAME  www.domainb.example.
www.domainb.example.    A      192.0.2.23

You would also have to ensure that any MX records (tells mail servers where to send email for a domain) for DomainA.example are updated to point to the host at DomainB.example so email can be routed accordingly (if necessary).

Justin Pearce
  • 1.1k
  • 5
  • 11