Prevent PHP from accessing the parent directory

Viewed 2285

I have a website hosted in the directory: /var/www/website.com.

This directory and all its subfolders allow the execution of PHP code. However, I would like to prevent the PHP files that are in a specific folder (/var/www/website.com/subfolder) from accessing the parent folder and listing its files.

Example: a PHP function like scandir() should be allowed to list all folders, subfolders and files that are in (/var/www/website.com/subfolder), but should NOT be allowed to list files below that level.

Do you know how a behavior like this could be implemented (with Nginx preferably)?

2 Answers
Related