Skip to content

Instantly share code, notes, and snippets.

@ssv445
Last active August 6, 2020 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssv445/db3d7160a9c34fb1c25dd243bf5c1839 to your computer and use it in GitHub Desktop.
Save ssv445/db3d7160a9c34fb1c25dd243bf5c1839 to your computer and use it in GitHub Desktop.
Laravel Apache hide .env and several security settings via .htaccess
# Disable Directory listing
Options -Indexes
# block files which needs to be hidden // in here specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
# in here specify full file name sperator '|'
<Files ~ "(artisan)$">
Order allow,deny
Deny from all
</Files>
<Files *.php>
Order Deny,Allow
Deny from all
</Files>
<Files index.php>
Order Allow,Deny
Allow from all
</Files>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/fake_folder
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/fake_folder
SSLEngine on
SSLCertificateFile /var/www/fake_folder/ssl/ssl.cert
SSLCertificateKeyFile /var/www/fake_folder/ssl/ssl.kety
</VirtualHost>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment