このサイト周辺のいくつかのスニペットに基づいて、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 は実際には機能していますが、まだ null です。私は何が欠けていますか?...または、FastCGI 環境との違いは何ですか?