I think that if in your version replace the next line
RewriteRule .* http://dom1/hi.php [R]
on
RewriteRule ^(.*)$ http://dom1/hi.php [R]
Although in essence your option should have worked.
Only here the data after the slash will be lost. If you want to transfer it to another url then:
RewriteRule ^(.*)$ http://dom1/hi.php$1 [R]
These parentheses are like variable values. You can get them through the operator $n , where the letter n is the number indicating which parenthesis (the value falling under this expression) on the account to take.
A URL like this dom2/aaa/bbb/ccc
RewriteRule ^(.*)/(.*)/(.*)$ http://dom1/hi.php$1 [R]
after RewriteRule ... redirected to http://dom1/hi.php/aaa . if you need to transfer bbb then we take the second parentheses, that is, $2 :
RewriteRule ^(.*)/(.*)/(.*)$ http://dom1/hi.php$2 [R]
And by analogy.
My suggestions:
You can use the RedirectMatch directive to force Apache to send the user somewhere else:
Option 1:
<VirtualHost *:80> ServerName dom2 RewriteEngine On RedirectMatch 301 ^(.*)$ http://dom1/hi.php$1 </VirtualHost>
Option 2:
<VirtualHost *:80> ServerName dom2 ServerAlias www.dom2 RedirectPermanent / http://dom1/hi.php ServerAdmin admin@redirectedurl.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
See the following:
RedirectMatch Directive
HTTP status codes 3xx