Inconsistent trailing slash in DOCUMENT_ROOT variable in PHP when using Apache

I have no idea why the slash is changing between your virtual hosts. By the way, is it important ? Just add a new slash to your programs (remove if a double slash is present) and the problem is solved.

I use

$realpath = realpath ($_SERVER['DOCUMENT_ROOT']."/");
$realpath = str_replace ("//", "/", $realpath);

Document root in an Apache environment can be defined in more than one place.

Yes, httpd.conf contains these settings, but they can be overwritten as this file is used for the default configuration.

I'd suggest you go check the vhost configuration under vhosts.d and sites-available directories.


http://httpd.apache.org/docs/2.0/mod/core.html says: The DocumentRoot should be specified without a trailing slash.