php检测apache mod_rewrite模块是否安装的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了php检测apache mod_rewrite模块是否安装的方法。分享给大家供大家参考。具体实现方法如下:

/**
 * @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;
}

使用方法:

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

希望本文所述对大家的php程序设计有所帮助。

相关文章

PHP中常用的魔术方法

我们在PHP中经常用到魔术方法,像构造方法,析构方法等等魔术变量,下面总结一下一些常用的魔术变量: __construct(),__destruct(),__clone(),__auto...

Windows下XDebug 手工配置与使用说明

1. 下载XDebug二进制文件: http://www.xdebug.org/download.php   5.2 http://www.xdebug.org/files/php_xd...

PHP Document 代码注释规范

1. 什么是phpDocumentor ? PHPDocumentor 是一个用PHP写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档。老的版本是...

用php实现批量查询清除一句话后门的代码

总是忘记一句话放到哪个文件里去了,直接全部干掉... 复制代码 代码如下:<?//xy7  if (!isset($dir) or empt...

PHP常用设计模式之委托设计模式

模式定义 委托是对一个类的功能进行扩展和复用的方法。它的做法是:写一个附加的类提供附加的功能,并使用原来的类的实例提供原有的功能。 假设我们有一个 TeamLead 类,将其既定任务委...