1

How to disable mod_deflate for PHP using the.htaccess file

  1. for files in a specific directory
  2. for all files that have extension of, for example .php?

I have tried both:

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

# for files that end with ".php"
<FilesMatch \.php$>
    SetEnv no-gzip 1
</FilesMatch>

They don't work, I can't figure out why. At this point I want to disable it completely for all files in the directory.

Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
Brian Royce
  • 11
  • 1
  • 3

2 Answers2

1

Check this out. and reply if it works for you:

SetEnvIfNoCase Request_URI ".php$" no-gzip dont-vary

Foksh
  • 41
  • 2
  • Didn't work I am still getting an error in FF Content Encoding Error The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. Please contact the website owners to inform them of this problem. – Brian Royce Jun 08 '12 at 16:09
  • Brian please include your .htaccess file as well as your mod_deflate statements. – Nicholas DiPiazza Jun 08 '12 at 16:16
  • There is nothing else in the .htaccess file just the one line. – Brian Royce Jun 08 '12 at 16:19
0

Let's simplify the issue and slowly make it more complicated as you get each piece working.

First, you stated in a comment: "When I try to access a specific php file on the server FF tells me that that there is a compression problem"

First, see if the issue happens when you disable mod_deflate. Comment out the deflate lines from your apache configuration file(s).

If that indeed fixes it, re-enable mod_deflate, then add these to your virtualhost that is hosting your site (don't mess around with .htaccess yet, that just adds another level of complexity):

SetEnvIfNoCase Request_URI "\.(php)$" no-gzip dont-vary

Try PHP files and see if they are still compressed.

If this works, then add the other condition

SetEnvIfNoCase Request_URI "^/foo/bar/.*" !no-gzip !dont-vary

Finally - put this all in your .htaccess file and Ta-dah!

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152