Home > Web > PHP >

Apache Mod Rewrite and PHP

Posted Jul 8, 2009
Last Updated Aug 13, 2013

If you need to test if an Apache server is running the mod_rewrite module, don’t waste your time building some elaborate system or doing it manually. Learn from my mistake and do it the simple way with this PHP code:

if (in_array('mod_rewrite', apache_get_modules())) { 
    // Apache has Mod Rewrite 
} else {
    // Apache DOES NOT have Mod Rewrite 

Thanks Andrew! Too bad I didn’t know about apache_get_modules() until after I had built something far more complex!


No HTML Tags are permitted.

Andrew Penry

Jul 9, 2009

One note: apache_get_modules() may not be available in all PHP versions if apache is running in CGI mode instead of in module mode. Make sure to test it on your installation.
Wall Worm plugins and scripts for 3ds Max