Using a directory in VirtualHost ServerName

me_pongo picture me_pongo · Apr 5, 2011 · Viewed 35.4k times · Source

I'm currently using name-based virtual host configuration, to server about 5 different websites from the same IP address, just like in the apache documentation:

<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

Is it possbile to have something like:

<VirtualHost *:80>
ServerName www.domain.tld/folderpath
DocumentRoot /www/software
</VirtualHost>

The webpages in this folder are using a different software stack, and I'd like to keep it nicely separate. I tried the method above but it didn't work.

Answer

Pekka picture Pekka · Apr 5, 2011

It's not possible the way you show - a VirtualHost is always just a host. But you could use an Alias.

<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain

Alias /folderpath /www/software

</VirtualHost>