Is it possible to detect mod_rewrite
in PHP when function apache_get_modules()
is not available?
views:
209answers:
2
A:
You can check if the rewrite.load file exists in the Apache mods-enable directory. In my Ubuntu system this file is located at /etc/apache2/mods-enabled/rewrite.load
When the module is disabled, the file is located at mods-available instead.
danielrmt
2009-08-19 16:35:43
Note that `mod_rewrite` can be included in an infinite number of locations, including `httpd.conf` itself. This'll be a solution only in Ubuntu and if the user is using Ubuntu's `a2enmod` function.
ceejayoz
2009-08-19 16:50:41
+1
A:
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);
Gumbo
2009-08-19 16:36:15
Wow, nice one, I wouldn't have thought of that. btw. You could use ob_get_clean() function.
tomp
2009-08-19 18:38:40
But `ob_get_clean` doesn’t end the buffer so you would need another `ob_end_*` call anyway.
Gumbo
2009-08-19 19:14:26
It actually does. In documentation is: ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean().
tomp
2009-08-19 19:39:19