The 4 Parts of a Premo WordPress HTACCESS File
Aug 15, 2014
Over the years working with WordPress, I’ve found a lot of good reasons to get used to modifying the HTACCESS file. The top four reasons to modify the HTACCESS include:
- Setting up 301 Redirects in the HTACCESS for WordPress
- Enabling Expires Handlers for images in the HTACCESS for WordPress
- Enabling Gzip Compression for WordPress code and texts
- Unsetting ETags
If you’re curious, read up on why you want Expires Handlers, Gzip Compression, and not ETags.
Please note! Your HTACCESS file is very important and sensitive. If you edit it, it may result in your site malfunctioning. Be sure that you duplicate the original file to ensure that you can restore your site if something should go wrong.
Plus – if your HTACCESS file is already modified (some plugins modify the HTACCESS file), you’ll need to be careful that you’re not duplicating commands or interrupting commands (again – backup before you make changes!).
If you do something different than me. Comment below – what’s in your HTACCESS?
##### # Premo WordPress HTACCESS # Author & URI: James Valeii, Jryven.com # Description: IfMod for Permalinks, Expires Header for Images, GZip for Texts and Codes, Unset ETags # Version: 1.0 # License: GPL2 ##### # Optional - Model for 301 Redirections. To Use Redirections, Copy the Redirect line without the pound # sign into the HTACCESS before "BEGIN WordPress" and adjust 'domain' 'sub(domain)' and 'slug' accordingly. ##### # Redirect 301 /sub/slug http://www.domain.com/sub/slug # Redirect 301 /slug http://www.domain.com/slug/ ##### ##### # BEGIN WordPress ##### RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] ##### # Expire images header ##### ExpiresActive On ExpiresDefault A0 ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType image/jpg A2592000 ExpiresByType image/jpeg A2592000 ExpiresByType image/ico A2592000 ExpiresByType text/css A2592000 ExpiresByType text/javascript A2592000 ##### # 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 AddType x-font/otf .otf AddType x-font/ttf .ttf AddType x-font/eot .eot AddType x-font/woff .woff AddType image/x-icon .ico AddType image/png .png ##### # Unset ETags ##### Header unset ETag FileETag None ##### # END WordPress #####