Jump to content

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');
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.