Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Sgouws
Created May 29, 2017 06:45
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 Sgouws/b51238941d66b1784a9fd85d8d817806 to your computer and use it in GitHub Desktop.
Save Sgouws/b51238941d66b1784a9fd85d8d817806 to your computer and use it in GitHub Desktop.
Useful .htaccess defaults
#If the config is not working, it will cause a 500.
## 404
ErrorDocument 404 /404.html
## basic compression
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js)$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
## Protect files and directories
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)? |xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
## Don’t show directory listings
Options -Indexes
## Basic rewrite rules, stop unneeded PERL bot, block subversion directories
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment