我试图弄清楚mod_rewrite是否可用,基于来自这个网站的几个片段:
$mod_rewrite = null;
if (function_exists('apache_get_modules')) {
$mod_rewrite = in_array('mod_rewrite', apache_get_modules());
}
if (is_null($mod_rewrite) && isset($_SERVER["HTTP_MOD_REWRITE"])){
$mod_rewrite = getenv('HTTP_MOD_REWRITE') == 'on' ? true : false ;
}
if (is_null($mod_rewrite)) {
ob_start();
phpinfo(INFO_MODULES);
$contents = ob_get_contents();
ob_end_clean();
if(strpos('_'.$contents, 'mod_rewrite') > 0) {
$mod_rewrite = true;
}
}
if (is_null($mod_rewrite)) {
$result = file_get_contents("http://".$_SERVER["SERVER_NAME"].FB_BASE."/asdfasdf/");
if (substr($result,0,14) === "<!DOCTYPE HTML>") $mod_rewrite = true;
}
除此之外,我在.htaccess中有这个:
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE on
</IfModule>
<IfModule !mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE off
</IfModule>`
所以在PHP版本5.3.3-7 + squeeze14中,CGI / FastCGI环境$ mod_rewrite仍为空,尽管它实际上正在工作。我错过了什么? ......或者在FastCGI环境中有什么不同?