How to set the VirtualDocumentRoot based on the files within
Posted
by Chuck Vose
on Server Fault
See other posts from Server Fault
or by Chuck Vose
Published on 2010-05-07T22:58:38Z
Indexed on
2010/05/08
15:08 UTC
Read the original article
Hit count: 442
apache
|mod-rewrite
I'm trying to set up Apache to use the VirtualDocumentRoot directive but my sites aren't all exactly the same. Most of the sites have a drupal folder which should be the root but there are a few really old drupal sites, a few rails sites, some django sites, etc. that want the Document root to be / or some other folder.
Is there a way to set up VirtualDocumentRoot based on a conditional or is there a way to use RewriteRule/Cond to detect that / is the incorrect folder if there is a drupal folder or a public folder?
Here's what I have so far:
<VirtualHost *:80>
# Wildcard ServerAlias, this is the default vhost if no specific vhost matches first.
ServerAlias *.unicorn.devserver.com
# Automatic ServerName, based on the HTTP_HOST header.
UseCanonicalName Off
# Automatic DocumentRoot. This uses the 4th level domain name as the document root,
# for example http://bar.foo.baz.com/ would respond with /Users/vosechu/Sites/bar/drupal.
VirtualDocumentRoot /Users/vosechu/Sites/%-4/drupal
</VirtualHost>
Thanks in advance!
-Chuck
© Server Fault or respective owner