I use VirtualDocumentRoot directive for dynamice virtual hosts on apache, now my virtualhosts are working well but wen I check the value of $_SERVER["DOCUMENT_ROOT"] it still have the value of first DocumentRoot definition not VirtualDocumentRoot value !
the brief part of my "http.conf" file is:
UseCanonicalName Off
DocumentRoot "/var/www/html"
<VirtualHost *:80>
ServerAdmin admin@localhost
VirtualDocumentRoot "/var/vhosts/%0"
ErrorLog "logs/dynamic-vhosts-error.log"
CustomLog "logs/dynamic-vhosts-access.log" combined
</VirtualHost>
when I run this php code bellow
<?php
echo $_SERVER["DOCUMENT_ROOT"];
?>
I get /var/www/html as result. If I comment this line
#DocumentRoot "/var/www/html"
the PHP result would be
/etc/httpd/htdocs
But I want the value of $_SERVER["DOCUMENT_ROOT"] be like this:
/var/vhosts/exampleDomain.com
Is there any solution for this?