tags:

views:

17

answers:

1

Hey folks

I'm trying to prepend a gzip script at the beginning of every file using

php_value  auto_prepend_file  gzip_start.php

in my .htaccess. The problem is that I've already got a document called combine.php that gzips it contents. What I need to know is, how I can exclude combine.php from the files who get the gzip prepended. I thought about using filesmatch, but can only figure out how to do it on just that one file, and not the exact opposite.

Any ideas?

A: 

Put this code at the beginning of gzip_start.php :

if( preg_match("/.*combine\.php.*/i", $_SERVER['PHP_SELF']) ) {
   // just output its content
}
else{
   // output gzipped content
}

Reading the PHP doc :

Specifies the name of a file that is automatically parsed before the main file. 
The file is included as if it was called with the require() function, so 
include_path is used.

In this case, gzip_start.php is included by every script you have, combine.php too, so you can check which script is including the file and then do the compression or skip it if the file has to be ignored.

Simone Margaritelli
I've already tried this solution, but didn't find it satisfying enough. The problem is that files that don't need cookies - images and such - now request a cookie. Unnecessary activity...If the file is detected by the server, I don't have to request the file like that.
lund.mikkel