Customizing htaccess question
Could someone please check this and see if everything looks correct and like it would work?
I'm a beginner and someone did this for me, but I need to be sure that it will work, and not cause harm to the site. Thanks!
RewriteEngine On
# Remove www from any URLs that have them
# make all urls with www goto https non www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
#Next fix it so all traffic is re-routed to https version of site
# make all urls https with out www go to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Modifications for speed March 9th 2019
# 2 weeks for most static assets
# set for two weeks max 14 days (60sec * 60min * 24hours * 14days)
Header set Cache-Control "max-age=1209600, public"
# Turn off etags
Header unset Etag
FileETag none
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
## EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
## EXPIRES CACHING ##
-
It looks fine, but I can't tell you if it will cause issues with your site, most likely it won't. In the event there is an issue caused by the .htaccess just remove the .htaccess. Thanks! 0 -
Thank you Lauren! 0 -
Oh, I was just checking GT Metrix, after adding the above to the htaccess file and uploading it, and Yslow said: Add Expires headers F (45) It showed this Google stuff - much of it js.?: - Removed - So I'm confused. I have and Expires Caching section with: ExpiresByType text/x-javascript "access plus 1 month" Is that not what they're talking about? I looked it up at another site and it says: # One month for most static assets Header set Cache-Control "max-age=2628000, public" Are these saying the same thing, or which should I use? 0 -
checking GT Metrix
They do provide more details on the site about this: Leverage browser caching | GTmetrix0 -
Yes Infopro, but that seems to be what I have now, yet they're saying at Yslow that I need it anyway. That was why I was thinking that perhaps the # One month for most static assets Header set Cache-Control "max-age=2628000, public" is doing something different? 0 -
Oh wait! I DO have both, but Yslow is apparently complaining on js that resides on Google's site! 0 -
Details! Now you're cooking with gas! :) 0
Please sign in to leave a comment.
Comments
7 comments