so you are not looking at redirection as such (as that happens at the app level ie on apache/nginx/wherever) but rather on the DNS resolution - host on which DomainA is hosted will or should never be hit - based on your description as you want the DNS requests to be resolved to the IPs of the DomainB. Unless I'm missing something in your request ?
As Shane pointed out DNS is not capable of HTTP redirection - that's an application/webserver duty. You could make DomainA and DomainB resolve to the same IP on DNS and all would work.But if you're looking to do this on per URL/per-path way then this is not possible - DNS is not capable of that - it's a simple DNS->IP service, what's happening with the actual URL is the webserver's task.
Ok, so after the comment below...what I'd do is to refer all DNS records for DomainA to the same IP(s) as DomainB is pointed to - this way you will get HTTP request hitting hostB and then it's just a simple matter of:
- A) creating a particular apache Name Baseed Virtual host - which will
be serving files from its own DocumentRoot
- B) creating permanent redirect on apache like this:
This will rewrite anything coming to DomainB to DomainA which can be hosted on the same server or somewhere else. I appreciate that the second option is probably an overhead and not necessary if you can/are allowed to create Name Based Virtual hosts on apache.
Redirect permanent / http://DomainA/
I'd go with a) - point all DNS records of DomainA to the same IP(s) as DomainB is pointing and create particular Name Based VirtualHosts on apache