View Full Version : How to disable the DEFLATE module for a specific directory?

06-27-2010, 11:33 PM
I am trying to figure out how to disable the DEFLATE module (gzipping) for a specific directory on my server. This is what I have in /etc/httpd/conf/httpd.conf

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

I can add something to my .htaccess file in the specific directory or even add a something to my /vhosts/domain.com/httpdocs/conf/vhosts.conf file. I can't seem to get it to work though. Any suggestions?

Tony M
06-28-2010, 12:28 AM
(You can see http://www.issociate.de/board/post/439274/disable_mod_deflate_per_site_or_dir.html)

Your Answer is:

If you added the DEFLATE filter using AddOutputFilter, you can remove it
using RemoveOutputFilter.

You can do this for a single file by nesting <Files> within <Directory>.

For example, this compresses all .php responses except for the response
from nocompress.php:

<Directory /var/www/myapp >
AddOutputFilter DEFLATE .txt .php .htm .html .cfm .xml .css .js
<Files nocompress.php>
RemoveOutputFilter .php
</Directory> :thumbsup:

06-28-2010, 07:41 AM
Hey Tony,

Thanks for the suggestion but still having no luck. I am wondering if it because I have the my AddOutputFilter DEFLATE in httpd.conf which is the setup all the sites on the server and for some reason it wont let me change those settings somewhere else. Maybe if i add gziping to each site in the vhost.conf file for each site?

Tony M
06-28-2010, 04:27 PM
I didn't know what is Your right purpose, Your answer might be:

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 ".jpg" SetEnv no-gzip 1

You might find You answers at:
http://hype-free.blogspot.com/2008/06/disabling-moddeflate-for-certain-files.html :)

06-30-2010, 06:56 AM
I removed my original code from /etc/httpd/conf/httpd.conf and added this to my vhost.conf on this domain

<Directory "/var/www/rockchurch.com/httpdocs">
AddOutputFilterByType DEFLATE html txt xml css js php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

php_admin_value open_basedir none
php_admin_value safe_mode off
Options FollowSymLinks

<Directory "/var/www/rockchurch.com/httpdocs/tiny">
RemoveOutputFilter DEFLATE html txt xml css js php

And works well. Apparently having it in /etc/httpd/conf/httpd.conf universally adds it to all domains, which is great, but can't be changed in specific directories elsewhere.