我对美分6进行了以下安装。
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/modules/mod_xsendfile.so
和apache_get_modules();在加载的mod数组中显示mod_xsendfile ...现在我有.htaccess文件包含
<Files files.php>
XSendFile on
</Files>
并且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)
在.htaccess文件中你有
<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"');
}
?>
别忘了更改配置 AllowOverride All for .htaccess