I am working on an e-commerce application in PHP. To keep URL\'s secure, product download links are kept behind PHP. There is a file, say downloa
To detect if the mod_xsendfile apache module installed, you can try this code:
if function_exists('apache_get_modules')
&& in_array('mod_xsendfile', apache_get_modules()) {
header("X-Sendfile");
}
But this code just check if the module installed only, that can cause errors if it's installed but configured wrongly
another possible way to do this to setup server-wide variable through Apache's .htaccess:
XSendFile On
XSendFileAllowAbove On
SetEnv MOD_X_SENDFILE_ENABLED 1
and check it form php code:
if ($_SERVER['MOD_X_SENDFILE_ENABLED']) {
Header(...)
}
The common idea is the same for nginx - just pass the value of status variable to backend via HTTP-header or CGI/FastCGI variable.