May
18
2017
.htaccess Internal Server Error while enabling Gzip
今天小V在使用gzip的时候遇到了一些问题,apache2.4的gzip开启和2.4以下版本有所区别,2.4中需要开启deflat_Module、headers_Module、filter_Module模块。以下是来自stackoverflow的网友配置方法:
There are different approchaes of achieving compression. Which one to use depends on the capabilities/setup of your server. It's always a good idea to surround blocks with <ifModule></ifModule> where possible, in order to prevent 500 status errors.
There's a good chance that the following will work on your local machine as well as on your server. However, with the sparse informatione provided, it's not possible to give a definite answer. But I'll gladly update this answer if this does not work and you can provide further debugging information.<ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|json|php|pl|svg)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_include mime ^application/json.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </ifModule> <ifModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf AddOutputFilterByType DEFLATE font/truetype font/opentype </ifModule> AddType image/svg+xml svg svgz AddEncoding gzip svgz
发表评论: