Skip to content

Instantly share code, notes, and snippets.

@ryanbattles
Created December 16, 2011 21:06
Show Gist options
  • Save ryanbattles/1487976 to your computer and use it in GitHub Desktop.
Save ryanbattles/1487976 to your computer and use it in GitHub Desktop.
A Standard .htaccess for use on most ExpressionEngine sites
FileETag None
<IfModule mod_rewrite.c>
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
# Uncomment to Remove www, but comment the above 2 lines out. :)
# Otherwise the world will end
# RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
# RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s or "No Input File" errors, or every page give the same thing
# make it /index.php?/$1 above -- Just adding the question mark
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 1 second"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-download "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment