Home >Backend Development >PHP Tutorial >Briefly describe how PHP detects whether the apache mod_rewrite module is installed
This article mainly introduces the method of PHP detecting whether the apache mod_rewrite module is installed. This detection function is realized by detecting the related functions of the apache mod_rewrite module. Friends in need can refer to the following.
The example of this article tells the story of PHP Method to detect whether the apache mod_rewrite module is installed.
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; }
Usage method:
if (!isRewriteMod()) exit('Please install Apache mod_rewrite module.');
Summary: The above is the entire content of this article, I hope it can be helpful to everyone Learning helps.
Related recommendations:
How to operate the database in php to determine whether the table exists
##How to use curl to connect to the website and obtain information in php
PHP implements simple GET, POST, Cookie, Session and other functions
The above is the detailed content of Briefly describe how PHP detects whether the apache mod_rewrite module is installed. For more information, please follow other related articles on the PHP Chinese website!