2012-07-10 107 views
3

我使用的Apache2 web服務器和我已經安裝了mod_xsendfile 我有類似:X-SENDFILE錯誤,未找到文件

   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點擊下載按鈕,它給我的錯誤,的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 /保護和埃羅現在是: (2)No such a file or directory: xsendfile cannot open file: /protected/file.zip,referer: http://domain.com/file/

回答

2

查找mod xsendfile文檔。您必須設置允許其提供文件的目錄。如果你已經這樣做了,那麼我會懷疑一些其他問題,例如符號鏈接沒有被提供,等等......

+0

我必須在.htaccess文件中設置/文件/文件夾中的這些目錄,在apache2。 conf或在/sites-available/domain.com? – takeit 2012-07-10 14:01:27

+1

根據文檔(https://tn123.org/mod_xsendfile/),指令 XSendFilePath/abs/path 應該可以在apache2.conf級別或在.htaccess文件中工作(假設允許覆蓋已設置)。 – Robert 2012-07-10 19:56:33

+0

謝謝你的工作:) – takeit 2012-07-11 16:13:28