Direct the web server to the shared directory in the project root folder
project root folder/public
but if you don’t have a shared folder and you are already pointing to the root folder, you can deny access by writing the following code in the .htaccess file.
<Files ".env"> Order Allow,Deny Deny from all Allow from 127.0.0.1 </Files>
in the above code, we first refuse all and allow only from our own server (localhost to the server) to run, and therefore we can protect it from external users.
source share