How to protect .env file in Laravel

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

    1. All except the Public folder to move to a higher level, such as a folder laravel - http://prntscr.com/bryvu7

    2. Change file publi_html/index.php line

      require __DIR__.'/../bootstrap/autoload.php';

    to

    require __DIR__.'/../laravel/bootstrap/autoload.php';
    

    And line

    $app = require_once __DIR__.'/../bootstrap/app.php';
    

    to

    $app = require_once __DIR__.'/../laravel/bootstrap/app.php';
    $app->bind('path.public', function() {
        return __DIR__;
    });
    
    1. Change file laravel/server.php line

      require_once __DIR__.'/public/index.php';

    to

    require_once __DIR__.'/index.php';
    

提交回复
热议问题