In order to do a 301 redirect, there needs to be a server at the specified location to reply to the browsersbrowser's request for content with a location like:
HTTP/1.1 301 Moved Permanently
Location: http://www.domainb.comexample
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.comDomainA.example
with DomainB.comDomainB.example
as the value. Your DNS zone might look something like:
NAME TYPE VALUE
--------------------------------------------------
www.domaina.comexample. CNAME www.domainb.comexample.
www.domainb.comexample. 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.comDomainA.example
are updated to point to the host at DomainB.comDomainB.example
so email can be routed accordingly (if necessary).