Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Last active May 26, 2018 13:00
Show Gist options
  • Save tieutantan/94db8c453ddaa90baff6c9e4b7c73ab7 to your computer and use it in GitHub Desktop.
Save tieutantan/94db8c453ddaa90baff6c9e4b7c73ab7 to your computer and use it in GitHub Desktop.
Block direct access .env file in Laravel
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<Files .env>
Order allow,deny
Deny from all
</Files>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment