auto_prepend_file删除附加文件的第一行

时间:2014-04-26 08:28:05

标签: php .htaccess prepend

将php.ini与

一起使用时
auto_prepend_file=/homepages/xyz/htdocs/somefile.php

在文件thickbox.css上(由于某些原因我必须将css文件作为php处理),第一行被删除。 thickbox.css的开头是

#TB_overlay {
    background: #000;
    opacity: 0.7;
    filter: alpha(opacity=70);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100050; /* Above DFW. */
}

但是带有前置文件的输出是

    background: #000;
    opacity: 0.7;
    filter: alpha(opacity=70);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100050; /* Above DFW. */
}

第一行消失了!

当我在#或换行符之前放置一个空格时,该行重新出现。但是,只要第一个字符是#,第一行就消失了。

我该如何防止这种情况?

1 个答案:

答案 0 :(得分:0)

我自己找到了解决方案。不应仅附加请求的css文件。相反,'somefile.php'应输出所请求的文件本身,最后包含以下行:

readfile($_SERVER['SCRIPT_FILENAME']); // the requested file
exit(0);