Skip to content

Instantly share code, notes, and snippets.

@hql287
Created December 17, 2013 04:42
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 hql287/8000162 to your computer and use it in GitHub Desktop.
Save hql287/8000162 to your computer and use it in GitHub Desktop.
.htaccess for ExpressionEngine
# SECURE .HTACCESS FILE
# ============================================================
<Files .htaccess>
order allow,deny
deny from all
</Files>
# DON'T SHOW ANY DIRECTORY WITHOUT AN INDEX FILE
# ============================================================
Options -Indexes
# DONT LIST FILES IN INDEX PAGES
# ============================================================
IndexIgnore *
# ADD A TRAILING SLASH TO PATHS WITHOUT AN EXTENSION
# ============================================================
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
# EE 404 PAGE FOR MISSING PAGES
# MAY DIFFER DEPENDING ON WHERE YOUR TEMPLATE IS LOCATED.
# ============================================================
ErrorDocument 404 /index.php?/site/404
# REMOVE INDEX.PHP
# ============================================================
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
#BROWSER HEADER CACHING
# ============================================================
ExpiresActive On
ExpiresByType text/html "access plus 1 days"
ExpiresByType image/gif "access plus 1 weeks"
ExpiresByType image/jpeg "access plus 1 weeks"
ExpiresByType image/jpg "access plus 1 weeks"
ExpiresByType image/png "access plus 1 weeks"
ExpiresByType image/x-icon "access plus 1 years"
ExpiresByType text/css "access plus 1 weeks"
ExpiresByType text/javascript "access plus 1 weeks"
ExpiresByType application/x-javascript "access plus 1 weeks"
ExpiresByType application/x-shockwave-flash "access plus 1 weeks"
# BEGIN CACHE-CONTROL HEADERS
# ============================================================
Header set Cache-Control "max-age=2592000, public"
Header set Cache-Control "max-age=604800, public"
Header set Cache-Control "max-age=216000, private"
Header set Cache-Control "max-age=600, private, must-revalidate"
# BEGIN TURN ETAGS OFF
# ============================================================
Header unset ETag
FileETag None
# BEGIN REMOVE LAST-MODIFIED HEADER
# ============================================================
Header unset Last-Modified
# BEGIN COMPRESS TEXT FILES
# ============================================================
SetOutputFilter DEFLATE
#REMOVE LAST-MODIFIED HEADER
# ============================================================
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
</filesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment