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

yipeiwu_com5年前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 获取一个月第一天与最后一天的代码

复制代码 代码如下:function getthemonth($date) { $firstday = date('Y-m-01', strtotime($date)); $lastda...

PHP实现登陆表单提交CSRF及验证码

PHP实现登陆表单提交CSRF及验证码

1、表单提交,并将其提交到本页 (1) form 属性method为post方法,修改路由,使其接收post、get的请求 Route::any('/admin/login','Admi...

PHP详细彻底学习Smarty

基本语法  所有的smarty标签都被加上了定界符.在smarty里,所有定界符以外的内容都是静态的,当smarty遇到了模板标签,将尝试解释他们,然后再以恰当的方式输出.&n...

PHP 模拟$_PUT实现代码

PHP里有$_GET,$_POST,但是没有$_PUT,所以如果需要使用它的话,则你不得不自己模拟一下: 复制代码 代码如下: $_PUT = array(); if ('PUT' ==...

php处理单文件、多文件上传代码分享

php处理  单文件、多文件上传实例代码,供大家参考,具体内容如下  后台处理文件submit_form_process.php  <?...