【问题标题】:PHP 7.0.22 : mod_deflate enabled & .htaccess in place but doesn't seem to do anythingPHP 7.0.22:启用了 mod_deflate & .htaccess 但似乎没有做任何事情
【发布时间】:2018-01-05 16:44:47
【问题描述】:

我有一个在 PHP 7.0.22 中使用 Plesk 的网站设置,作为 Apache 提供的 FPM 应用程序运行。

到目前为止,一切都运行良好,但是当我尝试在 .htaccess 中启用压缩时,因为我通常不会显示任何内容被压缩。

#SERVER COMPRESSION
<IfModule mod_deflate.c>
  SetOutputFilter DEFLATE
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/opentype

# For Olders Browsers Which Can't Handle Compression
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresByType image/jpg "access 1 year"
 ExpiresByType image/jpeg "access 1 year"
 ExpiresByType image/gif "access 1 year"
 ExpiresByType image/png "access 1 year"
 ExpiresByType image/svg "access 1 year"
 ExpiresByType text/css "access 1 month"
 ExpiresByType text/html "access 1 month"
 ExpiresByType application/pdf "access 1 month"
 ExpiresByType text/x-javascript "access 1 month"
 ExpiresByType application/x-shockwave-flash "access 1 month"
 ExpiresByType image/x-icon "access 1 year"
 ExpiresDefault "access 1 month"
</IfModule>

# 1 day for most static assets
<ifModule mod_headers.c>
 Header set Connection keep-alive
</ifModule>

我联系了服务器管理员,询问是否未启用 mod_deflate 模块,但已得到确认,已获得屏幕截图作为证据。

在这一点上有点难倒我应该从这里去哪里的任何想法?

【问题讨论】:

    标签: apache .htaccess deflate


    【解决方案1】:

    这可能是一个愚蠢的问题,我不确定您使用的是哪个版本的 Plesk,但是:

    • Plesk 中有“Apache 和 nginx 设置”图标吗?
    • 如果是这样,是否禁用了“直接由 nginx 提供静态文件”?如果没有,请尝试禁用它,看看是否有影响。*
    • 您也可以尝试使用其他代理复选框选项。

    *(如果启用了 mod_pagespeed,最好让它保持启用,但里面只有“htm html”,否则它们会显示为空白。)

    【讨论】:

      【解决方案2】:

      原来是因为托管环境是使用 Apache 和 Nginx 的混搭设置的。

      服务器管理员更新了 Nginx 指令以启用压缩。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-09
        • 1970-01-01
        • 2011-12-26
        • 1970-01-01
        • 2019-11-26
        • 2019-12-08
        • 2020-12-21
        相关资源
        最近更新 更多