0

I have two domains (a.com and b.com) and a.com is running on my apache server. I want web browsers that try to visit b.com to end up at a.com/?b (transparently, no redirect, and no second virtual host if possible).

I see that within the virtual host config i can rewrite (as shown here) but it's not clear and there are no examples.

Can someone propose the simplest way to solve this, ideally without another virtual host?


UPDATE:

I'm trying to solve it something like this. I think I'm close but a bit lost:

<virtualhost XXX.XXX.XXX.XXX:80>
        ServerName   a.com
        ServerAlias  b.com
        RewriteEngine On
        RewriteCond %{HTTP_HOST} (.*)\b\.com
        RewriteRule ^(.*) http://%1a.com/?b [L]
</VirtualHost>
TSG
  • 1,674
  • 7
  • 32
  • 51

1 Answers1

0

You could use Reverse HTTP proxy configuration on your apache server. Check this out

Your http server will be essentially serving content of another server. e.g.:

<VirtualHost *:*>
    ProxyPreserveHost On
    ProxyPass / http://a.com:8080/
    ProxyPassReverse / http://a.com:8080/
    ServerName b.com
</VirtualHost>
Dmitriy Kupch
  • 471
  • 2
  • 6
  • And it will need a virtualhost, just what the OP doesn't want. – Gerald Schneider Nov 23 '18 at 14:55
  • There is nothing bad with virtualhost, in this case it will not redirect the client, your webserver will essentially be able to serve clients requests in the following fashion. Cllient --> Your server A (Server A connects to server B for content) --> ServerB, Server B responds to server A, then the content is provided to the client by Server A. So in the headers clients will see only ServerA's IP. – Dmitriy Kupch Nov 23 '18 at 15:00