.htaccess Resources

Posted by Keefr February 10th, 2012

I’ve spent a fair amount of time as of late working in Apache’s .htaccess files for a myriad of reasons — including improving Google Page Speed numbers, password protecting sites and redirects. Its contents are powerful and uber-useful.

Here are a few resources I’d recommend for learning more about .htaccess files’ power and abilities:

Also, as a bonus, here are a few code snippets (LOVE TextExpander I use over and over to speed up sites and make Google Page Speed happier:

Enable GZIP:

php_value output_handler ob_gzhandler

Compression via Deflate:

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:

SetOutputFilter DEFLATE

Caching:


Header set Cache-Control “max-age=2592000″


ExpiresActive On
ExpiresByType text/html “access plus 1 seconds”
ExpiresByType image/gif “access plus 1 years”
ExpiresByType image/jpeg “access plus 1 years”
ExpiresByType image/png “access plus 1 years”
ExpiresByType image/x-icon “access plus 1 years”
ExpiresByType text/css “access plus 1 years”
ExpiresByType text/javascript “access plus 1 years”
ExpiresByType application/x-javascript “access plus 1 years”
ExpiresByType application/x-shockwave-flash “access plus 1 years”

Would love to get your feedback, additions, etc. on this, as I’m still building my skills, understanding and knowledge on all things .htaccess.

Trackback URL for this entry