How to change DOCUMENT_ROOT for PHP
Posted: Fri, Apr 22 01:22 AM (PDT)If you are running into issues with the $_SERVER["DOCUMENT_ROOT"] variable showing "/usr/local/data/www/"; when using PHP5 and need to have it point to your correct document root for your application, here is a simple tutorial for changing it.
Create a file document_root.php into your root application directory with follow the code:
<? $_SERVER["DOCUMENT_ROOT"] = "/vhosts/domain.com/" ?>
Add to your root application directory .htaccess with follow the code
php_value auto_prepend_file "/vhosts/domain.com/document_root.php"
This tells Apache to parse the document_root.php file before doing anything else.
Tags: