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程序设计有所帮助。

相关文章

PHP4和PHP5性能测试和对比 测试代码与环境

作者:heiyeluren博客:http://blog.csdn.net/heiyeshuwu时间:2007年8月6日PHP 4到今年年底PHP Group将不再对其进行支持了,所以为了...

使用PHP遍历文件目录与清除目录中文件的实现详解

今天无聊中练习了一下PHP遍历文件目录的程序,编写了以下两个程序,不过质量不是很好,轻拍~~~1、清除PHP缓存文件复制代码 代码如下:<?php  function r...

php解决crontab定时任务不能写入文件问题的方法分析

本文实例讲述了php解决crontab定时任务不能写入文件问题的方法。分享给大家供大家参考,具体如下: 今天使用crontab写的定时任务没有执行,很纳闷。 crontab.php...

PHP简单获取多个checkbox值的方法

本文实例讲述了PHP简单获取多个checkbox值的方法。分享给大家供大家参考,具体如下: HTML页面: <html> <head> </head...

php Smarty date_format [格式化时间日期]

Example 5-8. date_format[日期格式] index.php: 复制代码 代码如下: $smarty = new Smarty; $smarty->assign...