I was wondering if you could use a wildcard in the VirtualDocumentRoot directive. I mean is it possible to scan multiple directories with the VirtualDocumentRoot, like multiple home directories to look for sites?
Asked
Active
Viewed 1,701 times
1 Answers
4
Use of wildcards in the VirtualDocumentRoot
directive is not possible using Apache 2.2.3.
A correct VirtualHost entry for HTTP requests looks like this:
<IfModule mod_vhost_alias.c>
<VirtualHost *:80>
ServerAlias *
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/log/httpd/access_log vcommon
VirtualDocumentRoot /var/www/vhosts/shared/%0
VirtualScriptAlias /var/www/vhosts/shared/%0
</VirtualHost>
</IfModule>
This will serve a request to subdir.mydomain.com
from the directory /var/www/vhosts/shared/subdir.mydomain.com
To serve HTTPS requests too, duplicate this and replace *:80
with *:81

Andy
- 17,423
- 9
- 52
- 69
-
Hey Andy, I am running 2.2.14 on Ubuntu 10.04 - and using this code if I get a request to ANY subdomain, will it forward it to http://domain.com/subdomain ? – iUsable Sep 27 '11 at 09:28
-
@iUsable That sounds like you've got `mod_proxy` or an `.htaccess` rewrite involved, although it could be to do with the order of directives in your `httpd.conf`. You'd be better asking in a fresh question with more detail, link to it here and I'll have a look. – Andy Sep 27 '11 at 22:18