gpt4 book ai didi

wordpress - mod deflate 不压缩根目录的子目录

转载 作者:行者123 更新时间:2023-12-03 06:47:01 25 4
gpt4 key购买 nike

我花了大约 48 小时尝试解决 gzip deflate 问题,并意识到我可能需要寻求帮助,呵呵。

在意识到我需要在 php.ini 文件中打开压缩之后,我终于通过 .htaccess 在我的共享 Unix 服务器上启用了 deflate 模块。

PageSpeed 告诉我,我的根 HTML 是使用 gzip 为网站进行编码的,并且我的 WordPress 网站 theoleandersofsanleon.com 获得了 77.3% 的压缩率,但任何子目录中的文件都没有被压缩(主要是 css 和 js 文件)在我的 WordPress 目录及其子目录中)。

我认为没有必要,但我继续尝试使用指令 Directory 和指令 Location 但无济于事。

如果您需要查看任何服务器规范,我在根目录中放置了一个 phpinfo.php 文件。

这是我的 htdocs 目录和 wordpress 目录的 .htaccess 文件中的内容:

<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
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 application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

如果您需要更多信息,请告诉我,非常感谢您的帮助,我们将不胜感激,我将能够开始让我的头发重新长出来 8-)

最佳答案

在顶级 .htaccess 文件中尝试此操作。这是在 cPanel 中使用优化器时生成的内容。

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>

<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

关于wordpress - mod deflate 不压缩根目录的子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13871156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com