'Apache httpd Redirect rule using mod_rewrite engine based on string in the url

My url is https://test.com/#/logmein How can I redirect base on below condition using mod_rewrite?

If the url has logmein string and orgin of the request is from 10...* redirect to xyz.com else redirect to abc.com



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source