Options +FollowSymLinks -Indexes RewriteEngine On RewriteBase / ########################################################### # INode can cause problems in Etags so we remove it from # the calculation (see # http://developer.yahoo.com/performance/rules.html#etags) FileETag -INode +MTime +Size ########################################################### # GZIP text files AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript ########################################################### # cache control ExpiresActive On ExpiresByType text/css "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" ExpiresByType application/x-javascript "access plus 1 year" 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/html "access plus 1 month" ########################################################### # There's nothing worse than clicking a PDF link and having # Acrobat take over your web browser, so... # Ask what to do about all PDF files, don't just open Acrobat SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf Header add Content-Disposition "Attachment" env=requested_pdf ########################################################### # Redirect from www.example.com to example.com to ensure # consistent indexing (see http://no-www.org/ and # http://www.mattcutts.com/blog/seo-advice-url-canonicalization/) RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=permanent,L] ########################################################### # Run-time JPEG resizing RewriteCond %{QUERY_STRING} ^(thumb|gallery|feed)$ [nocase] RewriteRule ^(.+\.jp[e]?g)$ /scripts/jpeg_format.php?src=/$1&mode=%1 [L,NC] ########################################################### # Run-time CSS compression RewriteRule ^(.+\.css)$ /scripts/css_compress.php?src=/$1 [L,NC] ########################################################### # Run-time JS compression RewriteRule ^(.+\.js)$ /scripts/js_compress.php?src=/$1 [L,NC] ########################################################### # I prefer to build sites without trailing slashes, so... # If the page is not found and there is a trailing slash, # remove the slash and re-run all the rewrite rules RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^.]+)/$ $1 [R=permanent,N,QSA]