0

を使用して、すべてのファイルの先頭に gzip スクリプトを追加しようとしています

php_value  auto_prepend_file  gzip_start.php

私の.htaccessで。問題は、その内容を gzip で圧縮する、combine.php というドキュメントを既に持っていることです。私が知る必要があるのは、gzip を先頭に追加するファイルから、combine.php を除外する方法です。私は filesmatch を使用することを考えましたが、その1つのファイルだけでそれを行う方法を理解することしかできず、正反対ではありません.

何か案は?

4

1 に答える 1

0

このコードを gzip_start.php の先頭に置きます:

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

PHPドキュメントを読む:

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.

この場合、gzip_start.php はすべてのスクリプトに含まれているため、combine.php も含まれているため、どのスクリプトがファイルをインクルードしているかを確認し、圧縮を行うか、ファイルを無視する必要がある場合はスキップできます。

于 2010-05-02T21:59:23.813 に答える