Php – How to update the php DOCUMENT_ROOT variable from VirtualDocumentRoot

apache-2.2PHP

I am using VirtualDocumentRoot in my Virtual host configuration.

My VirtualDocumentRoot is set to /var/www/%1/ and if I create a folder say test, it is working as expected. The problem is, when I am using $_SERVER["DOCUMENT_ROOT"] in my php
files it is retuning /var/www. Is it possible to have php return the same path for $_SERVER["DOCUMENT_ROOT"] as configured in VirtualDocumentRoot.

Best Answer

If you can edit your PHP, you could calculate the correct DOCUMENT_ROOT and update the variable on the bootstrap. Here is an example: http://blog.suffolk-web-design.co.uk/2008/09/apache-automatic-sites-using.html

Related Topic