-2
I am making use of a MVC structure with PHP and, for security purposes, my index.php file that loads the configuration files and gives the bootstrap in the project is inside the folder public/
. Below is the project folder structure.
I need to make sure that when the user accesses the site (as I am in development environment, it would be: http://localhost/estrutura_mvc/
), it is redirected to the file public/index.php
and that this folder is the only one accessible to the user. I’m usually able to redirect to the index.php file using the following code in .htaccess
:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./public/index.php?route=/$1 [L,QSA]
However, this way the user has full access to files that are at the root of the project (for example: http://localhost/estrutura_mvc/.env
returns the contents of this file without any kind of restriction). How do I make sure that the only files he has access to are the ones in the folder public/
?