How do I edit the htaccess file to optimize my website?

My advice to you is not to worry about adding in the copious amount of .htaccess rules for forcing browser caching and setting correct expire time values for assets. If you download the W3 Total Cache plugin it handles adding all of the above into your .htaccess file for you.

If you would prefer not to install the caching plugin, I’ve taken the liberty of opening up my own sites .htaccess file and copying the optimisation rules and put them into a Github Gist for you.

Paste all of the code in the Gist at the top of your .htaccess file before the “# BEGIN WordPress” comment.

The Gist can be seen here.