X-Sendfile specific configuration .htaccess questions

5.8k views Asked by At

I already have a question open about this, I don't know the etiquette for posting again but I feel that the previous question is going down a wrong path.

I have been researching all day on the topic of configuring XSendfile to work with PHP on our apache server. The more I read, the more wildly contradictory the information I am getting.

So, if someone is reasonably familiar with XSendfile, your clarification would be extremely helpful and appreciated at this point.

The host says they have installed XSendfile. When I try to run a test XSendfile script, I get no errors, just a 0kb file. So I am assuming they have actually installed the thing.

Next, many posts on the net suggest that a 0kb file is down to a configuration problem. It seems that the more recent versions of XSendfile need these lines:

XSendFile On
XSendFilePath /path/to/files/directory

In either the apache config or the htaccess file. Whenever I put these lines into the local htaccess file, it crashes the entire site with a 500 error. If I put them at the top or the bottom, or whatever path I choose to put in the second line, it crashes the whole site.

A few hours ago I read that someone spoke to the author and that in fact you cannot configure XSendfile in htaccess, only in the apache config. Is it possible to configure XSendfile with htaccess or not? Half the sites say yes, half the sites say no or just talk about apache config.

IF it is possible to do it with htaccess, could anyone give me an example of an htaccess that wont crash the whole site? My htaccess currently contains these 3 lines:

Options -Indexes
ErrorDocument 404 /index.html
ErrorDocument 403 /index.html

Sorry if I sound stressed, this is a real thorn in the side of the deadline for this project and I can't seem to get a straight answer or find the right info anywhere.

1

There are 1 answers

1
Edward Williams On

Okay this was a bit tricky and not quite solved yet, but the part that this question pertains to, re paths, htaccess etc. is now solved.

So for anyone else who may be struggling with this, or who finds the documentation a bit unclear, I will put down what I have found out.

Some sites will say that you can put

XSendFile On
XSendFilePath /path/to/files/directory

in the .htaccess file. This is not correct. You can put XSendFile On in the htaccess. The XSendFilePath directive must go in the server config. Make sure that you specify the correct path to the directory you want to give XSendfile access to. If you do not have access to the server config files you can ask your host company if they can configure this for you.