Skip to content

Instantly share code, notes, and snippets.

@MatthewCallis
Created May 31, 2011 20:50
Show Gist options
  • Save MatthewCallis/1001258 to your computer and use it in GitHub Desktop.
Save MatthewCallis/1001258 to your computer and use it in GitHub Desktop.
A simple .htaccess template for simple sites. By no means perfect, but a good starting point.
# Set some defaults and don't show server type
AddDefaultCharset UTF-8
DefaultLanguage en-US
ServerSignature Off
# Don't show directory indexes and follow links
Options -Indexes
Options +FollowSymLinks
# Missing File Types and allow PHP in .htm files
AddType application/octet-stream 7z
AddType application/x-xpinstall xpi
AddType application/x-rar-compressed rar
AddType application/x-httpd-php .htm
# Compress files that need to be compressed
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|xml|ico|txt|htm|html)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
# Handle eTags
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|xml)$">
Header unset ETag
FileETag None
Header set Cache-Control "public"
#Header set Vary "Accept-Encoding,Accept"
#Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT"
</FilesMatch>
</IfModule>
# Add far future expires headers
<IfModule mod_expires.c>
<FilesMatch "\.(ico|jpg|gif|png|css|js|xml)$">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</FilesMatch>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment