How to protect .env file in Laravel

后端 未结 6 1016
甜味超标
甜味超标 2021-01-11 11:30

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 :

         


        
6条回答
  •  北荒
    北荒 (楼主)
    2021-01-11 11:43

    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!

提交回复
热议问题