Here's the problem I have been facing lately - a misconfigured apache on the web host. This means that all scripts that rely on $_SERVER['DOCUMENT_ROOT'] break. The easiest workaround I found just sets a variable in some publicly accessible files, but it hurts not to forget about it. My question is: how can I correctly determine the root directory of a document?
For example, on one host, the installation looks like this:
$_SERVER['DOCUMENT_ROOT'] == '/htdocs'
Real document roots:
test.example.com -> /data/htdocs/example.com/test www.example.com -> /data/htdocs/example.com/www
And I would like the script to be run from www.example.com/blog/ (on the path /data/htdocs/example.com/www/blog ) to get the correct value /data/htdocs/example.com/www .
On another host, the installation is slightly different:
$_SERVER['DOCUMENT_ROOT'] == '/srv' test.example.com -> /home/virtual_web/example.com/public_html/test www.example.com -> /home/virtual_web/example.com/public_html/www
Is there any solution? Or is this the only way to simply not rely on $_SERVER['DOCUMENT_ROOT'] and fix all the software that I run on my sites? Fixing this on the hosting side does not seem to be an option; I have not yet encountered the host where it was configured correctly. The best I got is the root of the document pointing to www.example.com, which was at least inside open_basedir - they used another naming scheme, www.example.com will point to /u2/www/example_com/data/www/ .
php apache configuration
Kim sullivan
source share