Skip to content

Instantly share code, notes, and snippets.

@simongcc
Last active December 19, 2018 05:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simongcc/9ab45323c551cd8fb21ecbb01ba85efb to your computer and use it in GitHub Desktop.
Save simongcc/9ab45323c551cd8fb21ecbb01ba85efb to your computer and use it in GitHub Desktop.
.htaccess-notes
#htaccess apache .htaccess file notes, last tested in Apache 2.4.26
#################
# Disable index
#################
Options -Indexes
#################
# SSI Support
#################
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
# pass these files to the server for parsing
AddHandler server-parsed .html
AddHandler server-parsed .shtml
AddHandler server-parsed .htm
#################
# Other features
#################
# add support to Microsoft Font eot file
AddType application/vnd.ms-fontobject eot
#################
# gzip file types
#################
<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
###################
# add expire header
###################
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
##########################
# add cache-control header
##########################
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment