【问题标题】:Confilict between RewriteEngine and XSendFileRewriteEngine 和 XSendFile 之间的冲突
【发布时间】:2012-01-15 00:20:17
【问题描述】:

我有以下 PHP 代码

$filename = 'a56.flv';
$file = "C:/xampp/htdocs/site/flv/a56.flv";
header("Content-Type: application/force-download");
header('Content-Type: video/x-flv');
header('Content-Disposition: attachment; filename="' . addslashes($filename) . '"');
//header("Content-Type: application/octet-stream");
header("Content-Type: application/download; charset=UTF-8");
header("Content-Description: File Transfer");
header("X-Sendfile: $file");

当我直接调用脚本 (http://localhost/site/get2.php?ftype=flv&filename=a56.flv) 时,它可以正常工作,但只要使用 (http://localhost/site/vsrc_a56. flv) 它返回 404 页面和这个 apache 错误:

[Sun Jan 15 02:01:44 2012] [error] [client 127.0.0.1] (20024)The given path is misformatted or contained invalid characters: xsendfile: unable to find file: flv/a56.flv

我的 .htaccess 文件如下所示:

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
AddDefaultCharset UTF-8
#########ErrorDocument 404 
ErrorDocument 404 /site/404.php
RewriteEngine On
XSendFile on
RewriteRule ^vsrc_(.*)$  ./get2.php?ftype=flv&filename=$1 [L]

【问题讨论】:

    标签: php apache .htaccess mod-rewrite x-sendfile


    【解决方案1】:

    尝试在 RewriteRule 之前添加RewriteBase /site/

    【讨论】:

    • 它只适用于 R 标志 RewriteRule ^vsrc_(.*)$ ./get2.php?ftype=flv&filename=$1 [R,L]
    猜你喜欢
    • 2014-11-15
    • 2012-06-27
    • 2012-03-06
    • 2011-05-02
    • 2012-11-25
    • 2013-10-27
    • 2014-03-02
    • 2016-11-15
    • 2012-11-02
    相关资源
    最近更新 更多