Jump to content

How to access files outside web root...


Recommended Posts

Hi

 

As my application grows, I am becoming more and more concerned about my configuration and .INC files which are contained within sub directories of my web root folder.

 

I am lead to understand that it is good practice to move sensitive files (those containing passwords and mysql logon credentials) outside of the general www folder

 

How do I access those files in PHP with, say an include or required statement

 

I am currently using include'../configuration/config.php'  how do I access files above ../

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/294492-how-to-access-files-outside-web-root/
Share on other sites

Those .inc files can be renamed with a .php extension so they can't be visited and read as a text document

 

Create a new directory(folder) in the /var directory

let's use web_files as the new directory

give www-data permission for web_files

 

I create a new directory to keep them all in one place and also to prevent any accidental deletions or overwriting

 

You can then access as any other include or require

include('/var/web_files/configuration/config.php');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.