【问题标题】:xsendfile won't work with mod_rewritexsendfile 不适用于 mod_rewrite
【发布时间】:2012-09-30 08:16:30
【问题描述】:

我正在尝试从重写的 URL 发送文件。 在 .htaccess 文件中我有:

RewriteRule ^foo$ foo.php [L]

在 foo.php 中:

header("x-sendfile: ".$_SERVER["DOCUMENT_ROOT"]."/filesdir/test.txt");

当直接浏览到 foo.php 时,我看到了文件的内容,但是当浏览到 /foo 时,我得到了 404。

我试图搜索网络,但除了将 foo 重定向到 foo.php 之外找不到任何解决方案

有谁知道问题出在哪里以及如何解决?

【问题讨论】:

    标签: php apache mod-rewrite apache2 x-sendfile


    【解决方案1】:

    我解决了这个问题。

    在 httpd.conf 中有 XSendFilePath 指令,它是一个已解析的符号路径,而在 php 中,“filesdir”实际上是 XSendFilePath 中路径的符号链接。

    我已将符号链接添加到 XSendFilePath,现在一切正常!

    【讨论】:

    • 我遇到了和你一样的问题,但我不确定你的解决方案是否也适用于我的情况。只要我使用使用 getenv('document_root') 生成的绝对路径,它们就不应该使用任何符号链接,对吗?或者我现在错过了什么?你也好心看看我的帖子吗? (stackoverflow.com/questions/20705731/…)
    猜你喜欢
    • 1970-01-01
    • 2013-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-26
    • 2013-11-09
    • 1970-01-01
    • 2011-07-04
    相关资源
    最近更新 更多