【问题标题】:.htaccess Internal Server Error while enabling Gzip.htaccess 启用 Gzip 时发生内部服务器错误
【发布时间】:2017-07-04 09:19:06
【问题描述】:

我正在尝试在我的 wordpress 网站上启用 Gzip 压缩。但是当我尝试添加压缩代码时,我收到以下错误。


内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请通过 webmaster@coachhire4u.com 联系服务器管理员,告知他们此错误发生的时间,以及您在此错误之前执行的操作。

服务器错误日志中可能会提供有关此错误的更多信息。

此外,在尝试使用 ErrorDocument 处理请求时遇到 500 Internal Server Error 错误。

Apache/2.4.18 (Unix) OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.5.31 服务器位于 www.coachhire4u.com 端口 80


我的 .htaccess 文件,

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /


RewriteCond %{REQUEST_URI} ^/customer/quote/payment/
RewriteRule (\d+)/(\d+) http://www.coachhire4u.com/?c4u_payment_id=$1 

[L,R=301]


RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]


</IfModule>


# END WordPress

压缩码

 # Compress HTML File, CSS File, JavaScript File, Text File, XML File and Fonts
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf

请帮我解决这个问题。我知道有类似的帖子,但似乎都没有帮助

谢谢

【问题讨论】:

  • 每当您收到 500 错误时,请检查您的服务器日志,它会为您提供有关问题所在的重要提示。
  • 如何查看我的服务器日志?我正在通过 FTP 访问服务器
  • 如果您在 PHP 代码中使用 gzip,它可能在您的 PHP 安装中不可用。检查 phpinfo() 中已编译的内容和未编译的内容。
  • 如果是专用服务器,它在 /var/log 中的某个位置。如果是共享服务器,它们通常会为您提供访问服务器日志的方法。
  • 抱歉找不到它。有没有其他方法可以调试这个问题?我正在尝试 2 天,它真的让我很沮丧..

标签: php wordpress apache .htaccess


【解决方案1】:

可能有点晚了,但我希望这会有所帮助。

我通过转到 httpd.conf 获取我的 Apache 服务器配置并取消注释包含 mod_filter.somod_deflate.so 的行来修复我的错误。

【讨论】:

    【解决方案2】:

    实现压缩有不同的方法。使用哪一个取决于您的服务器的功能/设置。在可能的情况下,最好用&lt;ifModule&gt;&lt;/ifModule&gt; 包围块,以防止出现 500 状态错误。

    以下内容很有可能会在您的本地计算机和服务器上运行。但是,由于提供的信息很少,无法给出明确的答案。但如果这不起作用,我很乐意更新这个答案,您可以提供进一步的调试信息。

    <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
    

    【讨论】:

    • 感谢您的回复。当我添加带有 标签的东西时,它没有效果。所以如果我在没有标签的情况下添加它,它会给出错误。
    • "它没有效果" => 你检查你的 get 请求的响应头了吗?您是否也尝试仅使用不带&lt;ifModule&gt; 的 mod_gzip-part?如果是这样,是否也导致了错误?
    • 我现在已经添加了上面的代码。但是数字仍然没有上升。当我删除 我得到相同的服务器错误
    • 您确定在您的网络服务器的httpd.conf 中启用了mod_gzipmod_deflate 吗?如果是共享主机,您必须寻求他们的支持。
    猜你喜欢
    • 2021-06-09
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 2014-10-31
    • 2016-07-16
    • 1970-01-01
    • 1970-01-01
    • 2016-09-22
    相关资源
    最近更新 更多