Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 23rd May 2012, 16:49
cbj4074 cbj4074 is offline
Senior Member
Join Date: Nov 2010
Posts: 395
Thanks: 30
Thanked 58 Times in 50 Posts
Default Preventing dynamically-served files from being gzipped (with clean URLs)


I (and others) have come to realize that IE 6/7/8 will double-compress any already-compressed file -- and fail to double-de-compress it -- when gzip compression is enabled for, e.g., a ZIP file download.

To work around this limitation, I need to have some means by which to exclude certain URLs from compression.

On its face, this seems simple enough, but this particular application requires the use of so-called "clean URLs". As such, Apache's SetEnvIf module seems not to be able to access the "clean URL"; it always sees "/index.php" for the "Request_URI".

I have this mod_rewrite rule:

# Rewrite URLs of the form 'index.php?q=x':
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
I was hoping to be able to force no-gzip with something like this:

SetEnvIfNoCase Request_URI (.*)(/|download/.*)$ no-gzip dont-vary
The idea is that anything that is in a "download" directory does not receive gzip compression (which is enabled site-wide).

The problem is that the SetEnvIf directive is never satisfied because, as stated above, Request_URI always equals the "true" URI, as it exists before the clean URL" rewriting is performed: "/index.php".

I considered using mod_rewrite to modify the CGI environment variables, but I don't like that solution because a) it very likely wouldn't work when PHP is running under Mod-PHP (as opposed to Fast-CGI), it wouldn't work if SuPHP is in use, and it may not even be possible to modify the "no-gzip" environment variable; the Apache docs state: "It is not possible to override or change the standard CGI variables using the environment manipulation directives."

Does anyone have any other ideas?

EDIT to add: This kind of thing doesn't work, for the reasons outlined above:

# Don't compress images (or other files that are already compressed)
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|zip|7z|rar|sit?x|mp3|flac|ogg|pdf)$ no-gzip dont-vary

Last edited by cbj4074; 23rd May 2012 at 16:55.
Reply With Quote
Sponsored Links


apache, cgi, gzip, mod_rewrite

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacked server Captain Installation/Configuration 8 23rd December 2010 11:39
ffmpeg Video support for ubuntu 7.10 [suphp-ispconfig] amaurib Installation/Configuration 13 16th February 2010 18:26
Debian 5.0 'hangs' GHz Installation/Configuration 5 1st October 2009 13:57
The system is currently updating the configuration files. warlock General 8 21st February 2009 19:15
Network questions regarding Ubuntu Server lubod Installation/Configuration 7 3rd January 2007 19:53

All times are GMT +2. The time now is 17:56.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.