Domain – How to setup apache to have two domains pointing to the same web app

apache-2.2domain

I have a web app running on http://domain.com and I just bought another domain http://domain2.com. Both domains are pointing to the same DNS servers and they are both pointing to the same IP address.

What is the best way or how should I setup my Apache config to get http://domain2.com/blah
to point to http://domain.com ?

So that…

would be the same thing as

Best Answer

Use an alias ! (Note that mod_alias has to be enabled)

<VirtualHost * >
    ServerName www.domain1.com
    DocumentRoot /var/www/domain1
</VirtualHost>

<VirtualHost * >
    ServerName www.domain2.com
    DocumentRoot /var/www/domain2
    Alias /blah /var/www/domain1
</VirtualHost>
Related Topic