home/successfullyinstalled. "; } else { $modRewriteWorking = performModRewriteTest(); if(!$modRewriteWorking) { createHtaccessAlternative(); $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 { restoreHtaccess(); echo "mod_rewrite doesn't appear to be working. Make sure:" . "" . "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(dirname(tempnam('adfadsfdas','')) . '/rewritetest', "w"); if($fp) { curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $testrewriting = file_get_contents(dirname(tempnam('adfadsfdas','')) . '/rewritetest'); unlink(dirname(tempnam('adfadsfdas','')) . '/rewritetest'); if($testrewriting == 'OK') { return true; } } } return false; } function createHtaccess() { $start = "### SILVERSTRIPE START ###\n"; $end= "\n### SILVERSTRIPE END ###"; $base = dirname($_SERVER['SCRIPT_NAME']); $rewrite = <<