RewriteEngine 和 XSendFile 之间的冲突

发布于 2024-12-27 02:20:09 字数 1122 浏览 1 评论 0原文

我有以下 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]

I have following PHP code

$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");

When I am calling script directly (http://localhost/site/get2.php?ftype=flv&filename=a56.flv) it works fine but as soon as calling with (http://localhost/site/vsrc_a56.flv) it returns 404 page and this apache error:

[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

Where my .htaccess file is like as below:

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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最单纯的乌龟 2025-01-03 02:20:09

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

Try adding RewriteBase /site/ before RewriteRule

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文