Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a directory in VirtualHost ServerName

Tags:

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.

like image 496
me_pongo Avatar asked Apr 05 '11 12:04

me_pongo


People also ask

What is Vhosts folder?

Apache Virtual Hosts allows you to run more than one website on a single machine. With Virtual Hosts, you can specify the site document root (the directory which contains the website files), create a separate security policy for each site, use different SSL certificates and much more.

How do I set up a name based VirtualHost?

The first step is to create a <VirtualHost> block for each different host that you would like to serve. Inside each <VirtualHost> block, you will need at minimum a ServerName directive to designate which host is served and a DocumentRoot directive to show where in the filesystem the content for that host lives.


2 Answers

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> 
like image 77
Pekka Avatar answered Oct 19 '22 21:10

Pekka


Is it possible to have a different vhost for each application like that:

<VirtualHost *:80>  ServerName www.domain.tld  DocumentRoot /www/domain  </VirtualHost>    <VirtualHost *:80>  ServerName www.domain.tld  Alias otherApp /www/otherApp  </VirtualHost>
like image 25
kmchen Avatar answered Oct 19 '22 21:10

kmchen