2013-07-03 33 views
0

我有美分6.X-SENDFILE不工作的centos

apache version :Apache 2.0 
httpd-tools-2.2.15-28.el6.centos.x86_64 
httpd-devel-2.2.15-28.el6.centos.x86_64 
httpd-2.2.15-28.el6.centos.x86_64 . 

在httpd.conf我已經添加了線下面安裝紙: 的LoadModule xsendfile_module的/ usr/lib64下/ httpd的/模塊/ mod_xsendfile。所以

和apache_get_modules();顯示mod_xsendfile在裝模陣列...現在我有一個包含

<Files files.php> 
XSendFile on 
</Files> 

.htaccess文件和files.php有

$path='fileliste.txt'; 
$documentMIME="text/plain"; 
$modules = apache_get_modules(); 
if (in_array("mod_xsendfile", $modules)) { 
header ("X-Sendfile: ". $path); 
header ("Content-Type: " . $documentMIME); 
//header ('Content-Disposition: attachment; filename="textfile"'); 
} 

每一件事似乎校正。但仍然沒有顯示任何文件。

+0

問題... –

+0

#AllowOverride控制可以在.htaccess中放置哪些指令 AllowOverride All。它不起作用,因爲AllowOverride被設置爲無 –

回答

0

在.htacess文件你有

<Files files.php> 
    XSendFile on 
</Files> 

和files.php是

<?php 

$file = "path_to_your_file"; 
$finfo = new finfo; 
    $mime = $finfo->file($file, FILEINFO_MIME_TYPE); 
if (in_array('mod_xsendfile', apache_get_modules())) 
{ 
header("X-Sendfile: $file"); 
header("Content-type: $mime"); 
//header ('Content-Disposition: attachment; filename="image"'); 
} 

?> 

不要忘記解決改變cofig 的AllowOverride所有的.htaccess