Using Apache2 on the A linux systemunix it is possible to method to have multiple VirtualDocumentRoot using mod_vhost_alias?
This really is naming convention I'm presently using and want to continue using:
host directory 127...1 domain domain.com 127...1 sub.domain domain.com_sub
Then during my vhosts portion of the httpd.conf I've:
NameVirtualHost 127...1 <VirtualHost 127...1> VirtualDocumentRoot /var/world wide web/%..com </VirtualHost> <VirtualHost 127...1> VirtualDocumentRoot /var/world wide web/%2..com_%1 </VirtualHost>
The issue with this is where I visit sub.domain the Apache error log shows that it's searching for /var/world wide web/sub.domain.com instead of /var/world wide web/domain.com_test that leads me to think it only reads the very first rule after which fails, but things i wish it to do is use any document root that satisfies either of these two VirtualDocumentRoot rules.
Apache typically will select the first virtual host whose
ServerAlias matches the host title provided within the
Host HTTP header. Inside your situation, since you've got no
ServerName directives, Apache allegedly utilizes a reverse DNS research around the Ip to fake a server title, and supposing the reverse DNS results in domain.com, which does not match, Apache then defaults towards the first virtual host. Sounds complicated, I understand... the end result is, you need to use
ServerAlias to create the configuration explicit. Try something a lot more like this:
NameVirtualHost 127...1 <VirtualHost 127...1> ServerName domain.com ServerAlias world wide web.domain.com VirtualDocumentRoot /var/world wide web/% </VirtualHost> <VirtualHost 127...1> ServerName sub.domain.com ServerAlias *.domain.com VirtualDocumentRoot /var/world wide web/%2.%3_%1 </VirtualHost>
Which should use
/var/world wide web/domain.com for http://domain.com and
/var/world wide web/world wide web.domain.com for http://world wide web.domain.com, each of which are offered through the first vhost, and
/var/world wide web/sub.domain.com for http://sub.domain.com,
/var/world wide web/blah.domain.com for http://blah.domain.com, and so forth.
You need to qualify the backreferences when you wish to place a '.' within the file path. So you must have it such as this:
VirtualDocumentRoot /var/world wide web/%2..%3_%1
Things I am realizing with this particular configuration is the fact that $_SERVER['DOCUMENT_ROOT'] is pointing to /var/world wide web/html and never towards the vhost's doc root. strange.
I simply authored your blog publish how you can setup your http proof server http://world wide web.devcha.com/2010/07/how-to-setup-your-http-proof-server.html
Concerning the OP and also the problem with "/var/world wide web/html" being set:
The issue I needed to it was using %1 rather than %2. Here's my working example:
ServerAlias world wide web.*.org.au UseCanonicalName Off VirtualDocumentRoot /path/to/sites/%2/pub
Hope that can help someone!
I just read the paperwork on "Directory Title Interpolation" in mod_vhost_alias paperwork.