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

PHP method to detect whether the apache mod_rewrite module is installed_PHP tutorial

WBOY
Release: 2016-07-13 10:03:15
Original
937 people have browsed it

How to detect whether the apache mod_rewrite module is installed in php

This article describes the method of detecting whether the apache mod_rewrite module is installed in 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;
}
Copy after login

How to use:

if (!isRewriteMod()) exit('Please install Apache mod_rewrite module.');
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969332.htmlTechArticleHow to detect whether the apache mod_rewrite module is installed in php. This example describes how to detect whether the apache mod_rewrite module is installed in php. Share it with everyone for your reference. Specific implementation method...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template