排除文件匹配中的文件

发布于 2024-08-31 18:01:57 字数 271 浏览 8 评论 0原文

使用的每个文件的开头添加一个 gzip 脚本

php_value  auto_prepend_file  gzip_start.php

我试图在 .htaccess 中 。问题是我已经有了一个名为combine.php 的文档,它对其内容进行了gzip 压缩。我需要知道的是,如何从预先添加 gzip 的文件中排除ombine.php。我考虑过使用 filesmatch,但只能弄清楚如何在一个文件上执行此操作,而不是完全相反。

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⒈起吃苦の倖褔 2024-09-07 18:01:57

将此代码放在 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 也是如此,因此您可以检查哪个脚本包含该文件,然后执行以下操作压缩或如果必须忽略文件则跳过它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文