Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to secure .env file in laravel 5.4?

I am Working with laravel 5.4. And i have problem with .env and composer.json file. Anyone can access from any browser and anyone can see my database credentials so please help me to protect this files.

like image 693
Nileshsinh Rathod Avatar asked Nov 28 '22 07:11

Nileshsinh Rathod


1 Answers

you can add following code to your .htaccess (make sure your .htaccess file should be in root folder not in public)file to deny the permission of .env file

  <FilesMatch "^\.env">
    Order allow,deny
    Deny from all
 </FilesMatch>
like image 128
sunilwananje Avatar answered Dec 25 '22 20:12

sunilwananje