3 in 1 htaccess file….. a go-to file
This deals with redirection from non-www to www, and also from http to secure https.
Then it also deals with expiration times for gtmetrix
## EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 1 year"
## EXPIRES CACHING ##
Header set Cache-Control "max-age=2592000, public"
Header set Cache-Control "max-age=2592000, public"
Header set Cache-Control "max-age=216000, private"
Header set Cache-Control "max-age=216000, public, must-revalidate"
Header set Cache-Control "max-age=1, private, must-revalidate"
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]