URL redirection with Custom DNS

Goal: Redirect domain A to domain B.

Used 'Custom DNS' for this but it doesn't work.
Is this the good approach?

Added an entry 'domain A' to local ip address.
On the local ip address a html file is hosted which redirects to 'domain B'.
When I visit the local site I'm redirected to 'domain B'
When I visit 'domain A' I'm not redirected.
nslookup domain A returns local ip address.

Is this possible anyway? Any help is appreciated.