How to prevent access .env of Laravel folder - using .htaccess

Problem:
When I hit my site with www.site.com/.env it returns the all database configuraton files. So, How to prevent access .env of Laravel folder.

Solution:
Create a .htaccess file which will forbidden the access of .env file. Create the folder in root directory in your project.

.htaccess file code

#Disable index view
options -Indexes

#hide a Specifuc File

<Files .env>
order allow,deny
Deny from all
</Files>



So, follow this step and now hit again www.site.com/.env , You can't get access of that page. It's access forbidden now.

[Hopes problem is solved. If any problem, just comment]

Tags: 
How to prevent access .env of Laravel folder - using .htaccess, how to stop accessing .env file in laravel
How to prevent access .env of Laravel folder - using .htaccess How to prevent access .env of Laravel folder - using .htaccess Reviewed by Maniruzzaman Akash on January 30, 2018 Rating: 5

No comments:

Powered by Blogger.