examples
examples copied to clipboard
Do not rely on function apache_get_modules() to detect mod_rewrite
In these two examples
https://github.com/nette/examples/blob/master/CD-collection/app/bootstrap.php#L31 https://github.com/nette/examples/blob/master/Modules-Usage/app/bootstrap.php#L32
function apache_get_modules
is used to detect mod_rewrite, but this is not reliable way, because this works only when PHP is installed as an Apache module. So it doesn't work with fastCGI, FPM or nginx configurations.
What is solution?
I think there is no possibility to check mod_rewrite from php, except trying it through a request with cURL or something.
It just seemed to me that it would be better to have the example without this check and let the setting on the programmer.
What you mean by βit doesn't work with fastCGI, FPM or nginx configurations.β? Examples don't work?
Examples work, but the detection doesn't. This is what happened: Someone created a website based on this example and put it on our hosting. It worked, until we changed PHP from apache_module to FPM.
If there were no apache-based detection, programmer would have to decide to use mod_rewrite or not himself at the start. And probability that some hosting drops mod_rewrite support is none (I hope).