Inconsistent trailing slash in DOCUMENT_ROOT variable in PHP when using Apache

Solution 1:

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);

Solution 2:

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