home/successfullyinstalled.
";
} else {
$modRewriteWorking = performModRewriteTest();
if(!$modRewriteWorking) {
copy(".htaccess_alternative", ".htaccess");
$modRewriteWorking = performModRewriteTest();
}
if($modRewriteWorking) {
echo "mod_rewrite is working! I will now try and direct you to
home/successfullyinstalled to confirm that the installation was successful.
";
} else {
unlink('.htaccess');
if(file_exists('.htaccess_orig')) {
copy('.htaccess_orig', '.htaccess');
}
echo "mod_rewrite doesn't appear to be working. Make sure:" .
"
" .
"- mod_rewrite is enabled in your httpd.conf
" .
"- AllowOverride is enabled for the current path.
" .
"
" .
"Please check these options, then refresh this page." .
"If you believe that your configuration is correct, click here to proceed anyway.";
}
}
function performModRewriteTest() {
$baseURL = dirname($_SERVER['SCRIPT_NAME']);
if($baseURL == "/") {
$baseURL = "";
}
// Check if mod_rewrite works properly
$location = 'http://' . (isset($_SERVER['PHP_AUTH_USER']) ? "$_SERVER[PHP_AUTH_USER]:$_SERVER[PHP_AUTH_PW]@" : '') . $_SERVER['HTTP_HOST'] . $baseURL . '/InstallerTest/testRewrite';
@$testrewriting = file_get_contents($location);
if($testrewriting == 'OK') {
return true;
}
// Workaround for 'URL file-access is disabled in the server configuration' using curl
if(function_exists('curl_init')) {
$ch = curl_init($location);
$fp = @fopen("temp", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$testrewriting = file_get_contents('temp');
unlink('temp');
if($testrewriting == 'OK') {
return true;
}
}
return false;
}
?>