Skip to content

Instantly share code, notes, and snippets.

@fedmich
Created March 19, 2012 06:28
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 fedmich/2098901 to your computer and use it in GitHub Desktop.
Save fedmich/2098901 to your computer and use it in GitHub Desktop.
HTaccess apache
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2692000 seconds"
ExpiresByType image/jpeg "access plus 2692000 seconds"
ExpiresByType image/png "access plus 2692000 seconds"
ExpiresByType image/gif "access plus 2692000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2692000 seconds"
ExpiresByType text/css "access plus 2692000 seconds"
ExpiresByType text/javascript "access plus 2692000 seconds"
ExpiresByType application/x-javascript "access plus 2692000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico|jpe?g|png|gif|swf|css|js)$">
Header set Cache-Control "max-age=2692000, public"
</FilesMatch>
<FilesMatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</FilesMatch>
Header unset ETag
Header unset Last-Modified
</IfModule>
#can also use as A = Access time, M = Modified time
#ExpiresByType image/jpeg A604800
#ExpiresByType image/jpeg M604800
#Redirect to noWWW urls
RewriteEngine On
RewriteCond %{HTTP_HOST} !^fedmich.com$ [NC]
RewriteRule ^(.*)$ http://fedmich.com/$1 [L,R=301]
#Redirect to noWWW urls
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.|$) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} MSIE
RewriteRule ^(restricted/.*)$ /ie-browser-resctricted [R=301,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment