2

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.

Community
  • 1
  • 1
Edward Williams
  • 307
  • 1
  • 7
  • 18
  • The etiquette is to edit the original question and make it better if you feel uncomfortable with it - not to "just" open a new question just because it was not fruitful so far for you. This will give you better answers as well. – hakre Jan 08 '12 at 13:32
  • possible duplicate of [XSendfile not working - PHP, Apache, Cpanel](http://stackoverflow.com/questions/8707944/xsendfile-not-working-php-apache-cpanel) – hakre Jan 08 '12 at 13:32
  • You will find a description why you get a 500 error in the error.log of apache (apache does not crash here, it's just signalling that there is a mis-configuration). I'm pretty sure it will turn out that the `XSendFilePath` directive can not be used inside `.htaccess`. – hakre Jan 08 '12 at 13:34
  • As assumed, the *context* of the *XSendFilePath* directive is: `server config, virtual host, directory` - not `.htaccess`. Use the documentation first if you need to find out things fast: https://tn123.org/mod_xsendfile/ – hakre Jan 08 '12 at 13:37

1 Answers1

4

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
Edward Williams
  • 307
  • 1
  • 7
  • 18
  • Even [the `mod_xsendfile` documentation](https://tn123.org/mod_xsendfile/) says that this is not possible. Whereas `XSendFile` has a context of _server config, virtual host, directory, .htaccess_, `XSendFilePath` has a context of _server config, virtual host, directory_ — note that .htaccess is *not* in that list. The `XSendFilePath` directive *must* be included in the httpd.conf or a file included into it, at server level, vhost level or directory level. – Owen Blacker Mar 05 '14 at 13:38