Apapche dynamic vhosts - document_root ??

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am using dynamic vhost on my apache development server (conf at end of

I am using $_SERVER['DOCUMENT_ROOT'] in the sites I am working on, which, as
you may have guessed isnt giving me the full path of the vhosts web root
folder (Its returning the value as set in my main apache conf file as it

Is there a way to get the full path to the web root folder from php or have
the value for document_root automatically munged by apache ?

#Simple dynamic virtual hosts
#   This extract from apache2.conf implements the virtual host arrangement
#   outlined at http://www.apache.org/docs/vhosts/mass.html , using
#   mod_vhost_alias.

# get the server name from the Host: header
UseCanonicalName Off
# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /mnt/raid/Net/%0/htdocs
#VirtualScriptAlias  /www/hosts/%0/cgi-bin


Re: Apapche dynamic vhosts - document_root ??

Quoted text here. Click to load it

Try something like dirname(__FILE__) or dirname($_SERVER['PHP_SELF'])

Re: Apapche dynamic vhosts - document_root ??

Chung Leong wrote:

Quoted text here. Click to load it

That works fine, but not in the context in which am using server
document_root - I really really dont want to have to hard code value for
document_root into my project as its being developed in several locations.

But on the same note, I really want dynamic virtual hosts - its such a
simple hassle free soloution


Site Timeline