xsendfile 不适用于 mod_rewrite [英] xsendfile won't work with mod_rewrite

查看:24
本文介绍了xsendfile 不适用于 mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to send file from a rewritten URL. Inside the .htaccess file I have:

RewriteRule ^foo$ foo.php [L]

在 foo.php 中:

In foo.php:

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

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

When browsing to foo.php directly I see the content of the file, but when browsing to /foo I get 404.

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

I've tried to search the web but couldn't find any solution for this other than redirecting foo to foo.php

有谁知道问题是什么以及如何解决它?

does anyone knows what's the problem and how to solve it?

推荐答案

我解决了这个问题.

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

In httpd.conf there was XSendFilePath directive which was a resolved symbol path while in the php there the "filesdir" was actually a symbolic link to the path in XSendFilePath.

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

I've add the symoblic link to XSendFilePath and now everything works well!

这篇关于xsendfile 不适用于 mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆