How to protect .env file in Laravel

后端 未结 6 1004
甜味超标
甜味超标 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:51

    In my case when was I host my project in shared hosting my .env file was accessible, my folder structure was like this Root |+ App | App | config | Database | Routes | Storage | .env | ... | index.php | .htaccess |+ css |+ js

    My .env file was accessible via this website.com/app/.env Solution Put all your public content to a folder name it public and change the root document path in settings [don't forget to change app.php path in index.php file] |+app |+public

    bootrap.php file path should be like this /../app/vendor/autload.php & /../app/bootstrap/app.php

提交回复
热议问题