2017-03-17 122 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