Skip to content

Instantly share code, notes, and snippets.

@lazuren
Created October 4, 2016 21:25
Show Gist options
  • Save lazuren/568cf14c03aebbe3e9ee7eea1760950f to your computer and use it in GitHub Desktop.
Save lazuren/568cf14c03aebbe3e9ee7eea1760950f to your computer and use it in GitHub Desktop.
Принудительное перенаправление на загрузки gzip архивов. Добавляем этот код в .htaccess и "ручками" архивируем необходимые для сжатия файлы и кладем их в ту же дерикторию
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
<FilesMatch .*\.js\.gz$>
ForceType text/javascript
Header set Content-Encoding gzip
Header append Vary Accept-Encoding
</FilesMatch>
<FilesMatch .*\.css\.gz$>
ForceType text/css
Header set Content-Encoding gzip
Header append Vary Accept-Encoding
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment