Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

php

apache

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

/var/www/html/Code/web/

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:

/var/www/html/Code/Controller/
like image 222
J_Strauton Avatar asked Aug 18 '15 08:08

J_Strauton


People also ask

Which root level folder are documents stored?

Finding the Document Root A domain's document root, also known as the home folder, is the main folder that contains all of the files for either a domain or a subdomain. The document root for your main domain name is your public_html folder.

How do I access files in root directory?

7. Double-click the hard drive under the right panel's Hard Disk Drives list. For your system drive, double-click the "C" drive. You should now see all the files and folders in the root folder of your hard drive.

What is the root directory of a folder?

Root folder (or root directory) is the top-level directory of a file system. It contains your store's source code and all other files.

How do I change the root of a document folder?

You can change the document root directory by moving the contents of the public_html directory to another directory, and then creating a symbolic link that points public_html to the new document root directory.


1 Answers

Use ../ to up one directory.

include($_SERVER['DOCUMENT_ROOT'] . '/../Controllers/MyFile.php');
like image 89
Al Amin Chayan Avatar answered Sep 30 '22 04:09

Al Amin Chayan