Is it possible to detect mod_rewrite in PHP when function apache_get_modules() is not available?
1 Answer
You could analyze the output of phpinfo():
ob_start();
phpinfo(INFO_MODULES);
$contents = ob_get_contents();
ob_end_clean();
var_dump(strpos($contents, 'mod_rewrite') !== false);
4 Comments
Tom Pažourek
Wow, nice one, I wouldn't have thought of that. btw. You could use ob_get_clean() function.
Gumbo
But
ob_get_clean doesn’t end the buffer so you would need another ob_end_* call anyway.Tom Pažourek
It actually does. In documentation is: ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean().
damianb
As a note, this doesn't appear to work when PHP is run FCGI. Not seeing anything as far as apache modules go in INFO_MODULES.