2016-11-08 2 views
1

내 사이트를 더 빠르게로드하는 방법과 관련하여 Google 페이지 속도 제안에 따라 Gzip 압축을 사용하려고합니다..htaccess 파일에서 gzip 압축 사용

https://varvy.com/pagespeed/enable-compression.html에있는 .htaccess 파일에 제안 된 추가를 시도했지만 제대로 작동하지 않습니다.

현재 .htaccess 파일에 다음 코드가 포함되어 있습니다. 다시 쓰기 규칙은 다양한 파일 형식의 캐싱과 마찬가지로 올바르게 작동합니다. .htaccess 파일 작업에 경험이 없으므로 명백한 오류가 발생하면 실례합니다. 나는이 문제를 읽으려고 노력했지만 필요한 답을 찾지 못하는 것 같습니다.

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example.co.uk [NC] 
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301] 

## EXPIRES CACHING ## 
<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresByType image/png "access 1 month" 
ExpiresByType text/css "access 1 month" 
ExpiresByType text/html "access 1 month" 
ExpiresByType text/x-javascript "access 1 month" 
ExpiresByType image/x-icon "access 1 month" 
ExpiresByType application/x-font-woff "access 1 month" 
ExpiresDefault "access 1 month" 
</IfModule> 
## EXPIRES CACHING ## 

<IfModule mod_headers.c> 
    <FilesMatch "\.(js|css|xml|gz|html|htm)$"> 
    Header append Vary: Accept-Encoding 
    </FilesMatch> 
</IfModule> 

<ifModule mod_gzip.c> 
mod_gzip_on Yes 
mod_gzip_dechunk Yes 
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ 
mod_gzip_item_include handler ^cgi-script$ 
mod_gzip_item_include mime ^text/.* 
mod_gzip_item_include mime ^application/x-javascript.* 
mod_gzip_item_exclude mime ^image/.* 
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
</ifModule> 

답변

1

mod_gzip 대신 mod_deflate가 필요합니다.

추가 내 htaccess로 파일에 다음과 지금은 제대로 파일을 압축 :

<FilesMatch "\.(html?|txt|css|js|php|pl)$"> 
    SetOutputFilter DEFLATE 
</FilesMatch>