I moved my project to HOST but I can still access .env with address mysite.com/.env and display this file with all variables and secure data. my .env file :
You are probably looking for how to stop .env files from being served on apache hence read.
do this on the /etc/apache2/apache.conf file - Ubuntu. after this part of that file
Require all denied
add the code below
# Hide a specific file
Order allow,deny
Deny from all
then restart your apache server with sudo service apache2 restart and enjoy!