如何使用 .htaccess 从目录中删除 Brotli 压缩和 Gzip 压缩

发布于 2025-01-09 11:27:25 字数 1015 浏览 0 评论 0原文

我的托管计划是带有 OpenLiteSpeed 的 cPanel,而不是 Apache。我在 cPanel 中打开了“压缩所有内容”设置。这似乎在某些地方使用 gzip,在其他地方使用 brotli。现在我需要防止某些目录进行这种压缩。我的托管计划给出的 .htaccess 规则是:

RemoveOutputFilter DEFLATE html txt xml css js php

但是,当我访问该网站然后检查 Chrome Dev Tools > 时,网络并点击主页,我仍然看到 Content-Encoding: br,表明 Brotli 仍在使用。因此,在进行一些测试时,我尝试了以下方法,但它们也都失败了:

RemoveOutputFilter BROTLI_COMPRESS;DEFLATE html txt xml css js php
RemoveOutputFilter BROTLI_COMPRESS DEFLATE html txt xml css js php
# place the following as a second line under RemoveOutputFilter DEFLATE html txt xml css js php
RemoveOutputFilter BROTLI_COMPRESS html txt xml css js php
# place the following as a second line under RemoveOutputFilter DEFLATE html txt xml css js php
RemoveOutputFilter BROTLI html txt xml css js php
# place the following as a second line under RemoveOutputFilter DEFLATE html txt xml css js php
RemoveOutputFilter BR html txt xml css js php

How do I close all Compression on a给定目录使用 .htaccess?

My hosting plan is cPanel with OpenLiteSpeed instead of Apache. I turned on Compress All Content setting in cPanel. This appears to use gzip in some places, brotli in others. Now I need to prevent some directories from having this compression. The .htaccess rule I was given by my hosting plan was:

RemoveOutputFilter DEFLATE html txt xml css js php

However, when I visit the website and then check Chrome Dev Tools > Network and click on the homepage, I still see Content-Encoding: br, indicating Brotli is still engaged. So, doing some tests, I tried the following and they all fail too:

RemoveOutputFilter BROTLI_COMPRESS;DEFLATE html txt xml css js php
RemoveOutputFilter BROTLI_COMPRESS DEFLATE html txt xml css js php
# place the following as a second line under RemoveOutputFilter DEFLATE html txt xml css js php
RemoveOutputFilter BROTLI_COMPRESS html txt xml css js php
# place the following as a second line under RemoveOutputFilter DEFLATE html txt xml css js php
RemoveOutputFilter BROTLI html txt xml css js php
# place the following as a second line under RemoveOutputFilter DEFLATE html txt xml css js php
RemoveOutputFilter BR html txt xml css js php

How do I turn off all compression on a given directory using .htaccess?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天赋异禀 2025-01-16 11:27:25

cPanel 采用 OpenLiteSpeed 而不是 Apache。

我假设您指的是 LiteSpeed Enterprise ,因为 OpenLiteSpeed 无法与 cPanel 一起使用,

<IfModule LiteSpeed>
  SetEnv no-brotli
  SetEnv no-gzip 1 
</IfModule>

尝试此 .htaccess 应该禁用 BR 和 GZIP

cPanel with OpenLiteSpeed instead of Apache.

I assume you mean the LiteSpeed Enterprise , as OpenLiteSpeed won't work with cPanel

<IfModule LiteSpeed>
  SetEnv no-brotli
  SetEnv no-gzip 1 
</IfModule>

try this to .htaccess should disable both BR and GZIP

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文