I'm working on a project with another dev. I noticed certain PHP scripts were failing on my workstation because include/require statements were neglecting to specify a trailing slash at the beginning of a path like so:
require $_SERVER["DOCUMENT_ROOT"] . "path/without/leading/slash.php";
These links were working on the dev server because the apache config there was specified with a trailing slash:
DocumentRoot "/var/www/html/"
I removed that trailing slash because the docs say The DocumentRoot should be specified without a trailing slash.
When I removed the trailing slash from the dev server's apache conf, it went away in $_SERVER["DOCUMENT_ROOT"] which made me happy because now the dev machine behaves like my workstation which is good for my sanity.
What is NOT good for my sanity is that the production server is still showing the trailing slash in _SERVRER["DOCUMENT_ROOT"] but there is no trailing slash specified in the apache conf. I've restarted apache and it's still there. I've searched my PHP code for any instance where this variable might be redefined to have a trailing slash but this returns no files:
sudo grep -r --include=*.php --color "DOCUMENT_ROOT.*=" /var/www
What the heck? While an include of /var/www/html//some/file/path.php doesn't seem to break, I worry it might at some point. Where is this trailing slash being added? Why is it different on the production server (RHEL 6.5 Santiago) than it is on the dev server (CentOS 6.5 final) or my workstation (Ubuntu)?