2017-03-17 121 views
0

我正在开发一个使用CodeIgniter HMVC的网站。CodeIgniter GZIP压缩问题

  1. 我已经在服务器(cPanel)中启用了GZIP压缩。
  2. 我在
  3. 我已在index.php文件的顶部增加ob_start("ob_gzhandler");笨配置($config['compress_output'] = TRUE;)启用压缩。
  4. 我在.htaccess文件中添加了DEFLATE。

当我测试根域(https://seocompany.us.com/)是GZIP压缩。

但是,当我测试任何其他页面(https://seocompany.us.com/services),错误显示GZIP未启用。

+0

你不需要执行步骤2和3,你可以做到这一切htaccess的 – Brad

+0

布拉德您好,我尝试了所有这些多次但从未工作。启用cpanel的GZIP在另一台服务器上工作,但不在我当前的服务器上。 –

回答

1

如果你在cPanel中做到了,那可能就够了。

或者你canJust做到这一点htaccess的

# Force compression for mangled headers. 
# http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping 
<IfModule mod_setenvif.c> 
    <IfModule mod_headers.c> 
     SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding 
     RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding 
    </IfModule> 
</IfModule> 

# Compress all output labeled with one of the following MIME-types 
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter` 
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines 
# as `AddOutputFilterByType` is still in the core directives). 
<IfModule mod_filter.c> 
    AddOutputFilterByType DEFLATE application/atom+xml \ 
            application/javascript \ 
            application/json \ 
            application/ld+json \ 
            application/rss+xml \ 
            application/vnd.ms-fontobject \ 
            application/x-font-ttf \ 
            application/x-web-app-manifest+json \ 
            application/xhtml+xml \ 
            application/xml \ 
            font/opentype \ 
            image/svg+xml \ 
            image/x-icon \ 
            text/css \ 
            text/html \ 
            text/plain \ 
            text/x-component \ 
            text/xml 
</IfModule> 

+0

嗨布拉德,我尝试了所有这些多次,但从来没有工作。启用cpanel的GZIP在另一台服务器上工作,但不在我当前的服务器上。 –

+0

Hi @brad感谢您的帮助,我实施了您的解决方案,但它返回相同的结果。我添加了截图供你参考http://prntscr.com/eltm4x –

+0

对不起,我不能帮忙。 – Brad