Home >Backend Development >PHP Tutorial >PHP method to detect whether the apache mod_rewrite module is installed, apachemod_rewrite_PHP tutorial

PHP method to detect whether the apache mod_rewrite module is installed, apachemod_rewrite_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:03:45735browse

How to detect whether apache mod_rewrite module is installed by php, apachemod_rewrite

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/967747.htmlTechArticlephp method to detect whether the apache mod_rewrite module is installed, apachemod_rewrite This article describes the method of php to detect whether the apache mod_rewrite module is installed . Share it with everyone for your reference...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn