Bug 28561 - DOCUMENT_ROOT is not using VirtualDocumentRoot
Summary: DOCUMENT_ROOT is not using VirtualDocumentRoot
Status: RESOLVED DUPLICATE of bug 26052
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_vhost_alias (show other bugs)
Version: 2.0.49
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Depends on:
Reported: 2004-04-23 18:30 UTC by Che Gonzalez
Modified: 2006-01-31 11:15 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Che Gonzalez 2004-04-23 18:30:13 UTC
if the DocumentRoot directive is specified, then DOCUMENT_ROOT uses the 
directive's value.  

if the VirtualDocumentRoot directive is specified, then DOCUMENT_ROOT still 
uses the directive's value.  

if the VirtualDocumentRoot directive is specified and DocumentRoot is not 
specified, then DOCUMENT_ROOT uses /apache/htdocs.

The conf info below uses the plain-vanilla httpd.conf with an include at the 
bottom that uses the information below.

UseCanonicalName Off

LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon

<Directory /web/www/>
Options FollowSymLinks
AllowOverride All

ServerName dev.posneradv.net
CustomLog logs/access_mass.log vcommon
VirtualDocumentRoot "c:/web/www/%1/"
Comment 1 Paul Querna 2004-04-29 01:38:52 UTC
Is this a bug?

It seems to me that this is the desired behavoir.  

mod_vhost_alias should not change the DOCUMENT_ROOT, rather it acts as a
ap_hook_translate_name(), only translating the requested vhost into a path.

-Paul Querna
Comment 2 André Malo 2004-04-29 05:32:38 UTC
No, it isn't. DOCUMENT_ROOT is one of the most useless variables, since it
doesn't (and cannot!) map things like Alias, RewriteRules, Userdir etc.
mod_vhost_alias falls unders the alias/rewrite category (technically and also on
a higher level of abstraction).
-> wontfix.
Comment 3 Christoph Dietz 2006-01-30 20:17:29 UTC
> No, it isn't. DOCUMENT_ROOT is one of the most useless variables, since it  
> doesn't (and cannot!) map things like Alias, RewriteRules, Userdir etc.  
How can you jugde on the needs of the administrator of an apache system?  
In our configuration DOCUMENT_ROOT would be a very, very usefull variable 
because I can't get the real filesystem path to the mod_vhost_aliased with any 
other variable, can I? 
I think, not setting DOCUMENT_ROOT for a mod_vhost_aliased VHOST is a bug, not 
a feature that have to be fixed. Otherwise we have to drop mod_vhost_alias and 
have to return to real vhosts and much "apache2ctrl graceful" restarts of the 
Apache2. This should not be solution, or? 
Comment 4 Ruediger Pluem 2006-01-30 21:47:46 UTC
This cannot be called a bug, but only an enhancement request. According to
http://httpd.apache.org/docs/2.0/vhosts/mass.html#overview DOCUMENT_ROOT cannot
be used in this situation. If you need to know the document root in an
environment variable please use mod_rewrite for mass virtual hosting
(http://httpd.apache.org/docs/2.0/vhosts/mass.html#simple.rewrite) and set a
custom variable using the E flag of mod_rewrite (DOCUMENT_ROOT cannot be
Comment 5 Reiner Keller 2006-01-31 14:49:19 UTC

a little precious than ChrisDi:

He/we use shtml files and therefore the DOCUMENT_ROOT is needed!

Even vor RewriteRules DOCUMENT_ROOT is useful - we have multiple Domains with
Typo3 installations and with the old apache1 the rules won't fit without this
variable - only with this writing:

    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}     !-f
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}     !-d
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}     !-l
    RewriteRule .*                                      /index.php


Comment 6 Joshua Slive 2006-01-31 20:15:39 UTC
That last comment is an excellent example of why DOCUMENT_ROOT symantics should
not be changed.  Two reasonable people could have two completely different ideas
about what the "proper" value for DOCUMENT_ROOT in those rules is.  If you start
playing around with this, there is really no way to consistently predict what
will be in DOCUMENT_ROOT, since it would change based on the phase of processing.

Making available a VIRTUAL_DOCUMENT_ROOT variable would seem like a sensible
alternative.  But this bug is a dupe, so please direct your propsed patches to
bug 26052.

*** This bug has been marked as a duplicate of 26052 ***