Skip to content
PHP Logo

What are the benefits of keeping sensitive PHP files in a separate, non-web-accessible directory?

Keeping sensitive PHP files in a separate, non-web-accessible directory helps to prevent unauthorized access to these files by users on the internet. By placing them outside of the web root directory, they cannot be accessed directly through a URL, adding an extra layer of security to your application.

php
// Example of keeping sensitive PHP files in a separate directory
include_once('/path/to/non/web-accessible-directory/config.php');