Two domains are directed to my single ip address. In the LAN, I have two Pi Apache servers. The router redirects port 80 traffic to 192.168.1.16. There, sites-available redirects domain2.com traffic to 192.168.1.11.
<VirtualHost *:80>
ServerName www.domain1.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.com
Redirect Permanent "/" "http://192.168.1.11/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My problem is that users accessing domain2.com are successfully redirected but see the URL as 192.168.1.11/blah.php, but I want them to see domain2.com/blah.php.
On 192.168.1.16, I've created a hosts entry "192.168.1.11 domain2.com", but if I change the domain2 redirection in sites-available to
Redirect Permanent "/" "http://domain2.com/"
the redirection isn't successful and domain2.com/blah.php doesn't load. "This site can’t provide a secure connection www.domain2 sent an invalid response".
How can I ensure that the users see the URL as "domain2.com" not "192.168.1.11"?