Apache hosting two sites on the same domain

apache-2.2virtualhostweb-hosting

I want to host two different websites on the same domain, example:

<VirtualHost *:80>
    DocumentRoot /var/www/www1/
    ServerName my.domain.com
    ...
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/www2/
    ServerName my.domain.com/www2
    ...
</VirtualHost>

This config is ofcourse wrong, but it depicts what I want to do. When someone go to my.domain.com he will be served by web application from /var/www/www1. When someone go to my.domain.com/www2 he will be served by web application from /var/www/www2. Is this possible in Apache?

Best Answer

You are not really configuring named virtual hosts or ip based virtual hosts, so forget about second VirtualHost entry and set an alias in first:

Alias /www2 /var/www/www2
Related Topic