Home > Software engineering >  How To Remove Brotli Compression and Gzip Compression from a Directory with .htaccess
How To Remove Brotli Compression and Gzip Compression from a Directory with .htaccess

Time:02-23

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?

CodePudding user response:

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

  • Related