【问题标题】:Mod_deflate not working on localhostMod_deflate 在本地主机上不起作用
【发布时间】:2018-01-02 14:35:12
【问题描述】:

我有 XAMPP 和 apache 版本 2.4.25 和 PHP 5.6,然后我在 apache 文件夹中的 httpd.conf 上启用了 mod_deflate 和 mod_filter:

LoadModule deflate_module modules/mod_deflate.so
LoadModule deflate_module modules/mod_filter.so

我安装了一个新的 codeignter 框架,然后在根文件夹中编写了一个 .httaccess 文件,如下所示:

RewriteEngine on
#RewriteBase /suli5
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

# compress text, html, javascript, css, xml:
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/jpg
AddOutputFilterByType DEFLATE text/html

# DEFLATE NOT COMPATIBLE BROWERS
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

重启apache然后我想验证压缩gzip是否运行,所以我检查一下

curl -I -H"Accept-Encoding: gzip" http://localhost/nees/

,但是还是没有

Content-Encoding: gzip

只给我这样的:

TP/1.1 200 OK
Date: Thu, 27 Jul 2017 03:26:00 GMT
Server: Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
X-Powered-By: PHP/5.6.30
Set-Cookie: ci_session=vmbl2tgvt838hb9mlbrg226f4hu7j43u; expires=Thu, 27-Jul-2017 05:26:00 GMT; Max-Age=7200; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html; charset=UTF-8

如何检查我的 mod_deflate 是否运行良好?

【问题讨论】:

  • 所以我尝试更改 但仍然无法正常工作。我正在使用 XAMPP
  • 你好 Andhika,你有没有得到这个工作?我也在尝试使用 mod_deflate,但它对我不起作用。不知道是不是笔误,但是在Apache中加载模块时,是LoadModule filter_module modules/mod_filter.so,而不是LoadModule deflate_module modules/mod_filter.so

标签: windows apache xampp gzip mod-deflate


【解决方案1】:

就我而言,我将其设置为 httpd.conf:

<IfModule deflate_module>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog "logs/deflate_log" deflate
</IfModule>

请注意,- deflate_module 是我的 mod_deflate 的别名。

【讨论】:

    猜你喜欢
    • 2015-02-25
    • 2011-02-15
    • 2015-03-19
    • 2017-07-22
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-15
    相关资源
    最近更新 更多