在Apache/PHP中使用X-Sendfile

20 php apache x-sendfile

我似乎找不到很多关于X-Sendfile或PHP示例代码的文档(有一些rails代码).

以前有人用过它,会介意快速提供代码片段和简要说明吗?

Don*_*eld 29

X-Sendfile是一个HTTP标头,所以你想要这样的东西:

header("X-Sendfile: $filename");
Run Code Online (Sandbox Code Playgroud)

如果配置正确,您的Web服务器会将其选中.这里有一些更多的细节:

http://www.jasny.net/articles/how-i-php-x-sendfile/

  • 对于未来的读者:XSendFileAllowAbove已被弃用; 使用XSendFilePath (3认同)