-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working using mod_rewrite links #12
Comments
I have this issue as well. Is there any way to get either this or subdirectories of allowed file paths working? |
I haven't find way around... |
I gave in and just redirected http://www.site.com/download/parameters/ to http://www.site.com/dl1.php?x=parameters |
I also had quite some issues when trying to send a file using xsendfile when mod_rewrite is active. |
I also have this problem, too. Sadly the above workaround is not a solution for me. I also have found out, that it is working by adding a absolute path the XSendFilePath config, but not by using the standard config and trying to access a file in the working directory. I just can't find a solution. Would you be so kind, to have a look at my post at In addition to that I might have found out somehting more about another problem/bug with php in cgi mode. |
_Therefore, I would always use absolute URIs in the The second consequence of the above is that the constructed path, not necessarily being what you expect, auto-whitelist a directory you do not expect, while then of course not whitelisting the directory you would have expected. _Therefore, always white-list URIs._ In short, Apache might not consider the same directory to be the current working directory of a request as you (or a backend *CGI). Rewriting only adds to the confusion. I actually considered dropping the relative paths/auto-whitelist stuff altogether for this reasons, because it can be admittedly very confusing, and is also under-documented. |
Thanks for the fast reply. At the moment I am using absolute links in the xsendfile header, but its still not working with mod_rewrite. The only other solution I can think about is to whitelist the root path of everything. But in this case I really would give access to every file on my server. This is not the best practice and also I'm not sure if my provider would allow this at all. Is there any way to get xsendfile working in this case? Maybe a possibility to override the request path information via PHP or anything else before calling the xsendfile header? Or do I maybe have to use another path than obvious to get it work? Would it be helpful if every mod_rewrite request looks exactly the same except one parameter? |
Store the files you want to serve with x-sendfile in a root that is OK to be served... I don't know of any way to patch up mod_xsendfile to work better with relative paths without making it non-generic. You may try to patch something together that works better for you, of course. Another idea might be to allow whitelisting of paths containing wildcards... |
Wildcards sounds interesting. In my case all files I want to serve are always in a folder (e.g.) called domain.com/download. There are very many domains, but all using the same structure, so a possibility to add all these public folders to the whitelist without having to add everything else would be really great. |
I guess no answer means that it's not possible right now? |
A suggested modification: Allow XSendFilePath to be specified in .htaccess. I think this would be very helpful for those of us who do not have access to the Apache configuration file. Otherwise we can't whitelist anything and have to rely on only using the working directory which seems to be difficult to determine if mod_rewrite is used. |
Hello, For instance in place to use: Use: Tell me if resolved your problem guys ! |
@raminasri this solved the problem! It is funny to answer after 7 years, but this was an important issue for me today and your answer solved the problem. Cheers! |
Hello,
I am having issues running XSendFile on Apache when using mod_rewrite to have custom download links.
For example download works when url is like http://www.site.com/dl1.php?x=parameters
RewriteRule ^download/(.*)/$ download.php?x=$1 [QSA,L]but doesn't work when having http://www.site.com/download/parameters/
and that is processed using mod_rewrite to
In my httpd.conf I have line "XSendFile On" and Apache was restarted...
I have also added that in .htaccess too but no success...
Can someone help me out on this one?
Best Regrards,
Tim
The text was updated successfully, but these errors were encountered: