Skip to content

Instantly share code, notes, and snippets.

@impshum
Created April 9, 2017 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save impshum/88f3ba4ccc8e3ef397f0ce19516faf00 to your computer and use it in GitHub Desktop.
Save impshum/88f3ba4ccc8e3ef397f0ce19516faf00 to your computer and use it in GitHub Desktop.
Force https, enable compression and caching in .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#Gzip
<ifmodule mod_deflate.c>
<ifmodule mod_mime.c>
Addtype font/opentype .otf
Addtype font/eot .eot
Addtype font/truetype .ttf
</ifmodule>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript text/text font/opentype font/truetype font/eot
</ifmodule>
#End Gzip
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment