14

How can I disable mod_deflate in Apache2

  • For files in a specific directory

OR

  • For all files that have extension of, for example .py?

3 Answers 3

30

You could set the environment variable no-gzip for that directory/type of file:

# for URL paths that begin with "/foo/bar/"
SetEnvIf Request_URI ^/foo/bar/ no-gzip=1

# for files that end with ".py"
<FilesMatch \.py$>
    SetEnv no-gzip 1
</FilesMatch>
2
  • 2
    can I do it in .htaccess file inside that folder?
    – wakandan
    Dec 18, 2009 at 3:52
  • 1
    @wakandan Yes, if your <Directory> configuration in your main httpd.conf contains AllowOverride All.
    – Chloe
    Mar 23, 2016 at 21:45
3

Quote from: scottlinux.com

Disable Compression: To disable compression in Apache, typically you just need to disable the module mod_deflate...

Debian/Ubuntu:

$ sudo a2dismod deflate
Module deflate disabled.
Run '/etc/init.d/apache2 restart' to activate new configuration!

$ sudo /etc/init.d/apache2 restart
2

Don't know if this is a general solution, but it worked for me at least, to turn of mod_deflate for .py-files within a .htaccess file in a certain folder:

SetEnvIfNoCase Request_URI "\.py$" no-gzip dont-vary
1
  • worked perfectly. I prefer a one-liner when debugging
    – Glenn Plas
    Feb 26, 2014 at 12:11

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.