xsendfile won't work with mod_rewrite

穿精又带淫゛_ 提交于 2019-12-11 09:31:41

问题


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

RewriteRule ^foo$ foo.php [L]

In foo.php:

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

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

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?


回答1:


I solved the problem.

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.

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



来源:https://stackoverflow.com/questions/12809526/xsendfile-wont-work-with-mod-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!