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

How To Remove Brotli Compression and Gzip Compression from a Directory with .htaccess

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

RemoveOutputFilter DEFLATE html txt xml css js php

但是,当我访问该网站然后检查 Chrome Dev Tools > Network 并单击主页时,我仍然看到 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

如何使用 .htaccess 关闭给定目录的所有压缩?

cPanel with OpenLiteSpeed instead of Apache.

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

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

试试这个 .htaccess 应该同时禁用 BR 和 GZIP