X-Sendfile错误,找不到文件


X-Sendfile error, file not found

我正在使用apache2 Web服务器,并且我已经安装了mod_xsendfile我有这样的东西:

                header('Content-type: application/zip');
                header('Content-Disposition: attachment; filename="file.zip"');
                //header("X-Accel-Redirect: /file/protected/file.zip"); //for nginx server
                header('X-Sendfile: /protected/file.zip');
                exit();

我在/etc/apache2/apache2.conf:中启用

XSendFile on

当我点击/file/index.php中的下载按钮时,它会给我一个错误,位于/file/Not-Found 中的index.php

我一开始试着移动header('X-Sendfile: /file/protected/file.zip');,但还是一样。。

当我使用header("X-Accel-Redirect: /file/protected/file.zip");时,它可以工作,但给了我空的.zip文件,无论如何,它不适用于apache2服务器。。

文件只有几个KB的

有人知道怎么修吗?

编辑:它在error.log中说:给定的路径在根路径之上:xsendfile:找不到文件:/protected/file.zip

我设置了XSendFilePath/protected,现在的错误是:(2)No such a file or directory: xsendfile cannot open file: /protected/file.zip,referer: http://domain.com/file/

查找mod xsendfile文档。您必须设置允许从中提供文件的目录。如果你已经这样做了,那么我会怀疑还有其他问题,比如符号链接没有得到服务,等等…