examples icon indicating copy to clipboard operation
examples copied to clipboard

Do not rely on function apache_get_modules() to detect mod_rewrite

Open zraly opened this issue 7 years ago β€’ 4 comments

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.

zraly avatar Jan 30 '17 09:01 zraly

What is solution?

dg avatar Jan 30 '17 12:01 dg

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.

zraly avatar Jan 30 '17 13:01 zraly

What you mean by β€žit doesn't work with fastCGI, FPM or nginx configurations.β€œ? Examples don't work?

dg avatar Jan 30 '17 18:01 dg

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).

zraly avatar Feb 02 '17 17:02 zraly