Skip to content

Instantly share code, notes, and snippets.

@jacks0n
Created May 10, 2014 14:28
Show Gist options
  • Save jacks0n/39c812b23abd639f6967 to your computer and use it in GitHub Desktop.
Save jacks0n/39c812b23abd639f6967 to your computer and use it in GitHub Desktop.
Default .htaccess
# Some sensible defaults
Options +FollowSymLinks -Indexes
AddDefaultCharset UTF-8
ServerSignature Off
# Hide sensitive information
RedirectMatch 404 /\.git
RedirectMatch 404 /*.sql
RedirectMatch 404 /Gruntfile.js
RedirectMatch 404 /package.json
RedirectMatch 404 /node_modules
# Turn off ETags
Header unset Pragma
Header unset ETag
FileETag None
# Enable GZIP
<IfModule mod_deflate.c>
# Static files
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
# Caching headers for assets
<IfModule mod_headers.c>
# 1 week
<FilesMatch \.(css|js)$>
Header append Vary User-Agent
Header append Vary Accept-Encoding
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 1 year
<FilesMatch \.(bmp|png|gif|jpeg|jpg|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt|eot|ttf|otf|svg)$>
Header set Cache-Control "max-age=31449600, public"
</FilesMatch>
</IfModule>
# Expires headers for assets
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 0 seconds"
<FilesMatch \.(bmp|png|gif|jpeg|jpg|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt|eot|ttf|otf|svg|txt|zip|tar.gz)$>
ExpiresDefault "access plus 1 month"
</FilesMatch>
<FilesMatch \.(js|css)$>
ExpiresDefault "access plus 1 week"
</FilesMatch>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment