How to get a file that's one folder above Document Root?


I have edited Apache so that my document root is here:


But now I want to point to a file that is inside the ~/Code/ folder.

Normally I could use:

include($_SERVER['DOCUMENT_ROOT'] . '/Controllers/MyFile.php');

But that won’t work with this new document root. So, without changing my document root, how can I point back to a folder that is in this path:



Use ../ to up one directory.

include($_SERVER['DOCUMENT_ROOT'] . '/../Controllers/MyFile.php');

Answered By – Al Amin Chayan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published