Friday 30 March 2018

apache - How to check if mod_rewrite is enabled in php?



I was wondering if it is possible to check if mod_rewrite is enabled on Apache AND IIS in PHP.



ModRewrite for IIS exists. Check it here.



So, I'm looking for a PHP script that checks for mod_rewrite on Apache and IIS.




Does anyone know such script or can write one?



Especially for Microsoft IIS.



Thanks!


Answer



If you're using mod_php, you can use apache_get_modules(). This will return an array of all enabled modules, so to check if mod_rewrite is enabled, you could simply do



in_array('mod_rewrite', apache_get_modules());



Unfortunately, you're most likely trying to do this with CGI, which makes it a little bit more difficult.



You can test it using the following, though



strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false


If the above condition evaluates to true, then mod_write is enabled.


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...