Exclude a file in a filematch
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 开发者_StackOverflow社区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?
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.
精彩评论