Home >Backend Development >PHP Tutorial >PHP method to detect whether the apache mod_rewrite module is installed, apachemod_rewrite_PHP tutorial
This article describes the method of detecting whether apache mod_rewrite module is installed by php. Share it with everyone for your reference. The specific implementation method is as follows:
/** * @title Check if Apache's mod_rewrite is installed. * * @author Pierre-Henry Soria <ph7software@gmail.com> * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved. * @return boolean */ function isRewriteMod() { if (function_exists('apache_get_modules')) { $aMods = apache_get_modules(); $bIsRewrite = in_array('mod_rewrite', $aMods); } else { $bIsRewrite = (strtolower(getenv('HTTP_MOD_REWRITE')) == 'on'); } return $bIsRewrite; }
How to use:
if (!isRewriteMod()) exit('Please install Apache mod_rewrite module.');
I hope this article will be helpful to everyone’s PHP programming design.