Simplify serving static assets in index.php

No need to perform custom file reading.
See https://github.com/laravel/laravel/blob/master/server.php#L18
and http://php.net/manual/en/features.commandline.webserver.php
This commit is contained in:
Ingo Schommer 2017-10-03 01:44:06 +13:00
parent 41b87ab2d5
commit a1384f67b7
1 changed files with 2 additions and 11 deletions

View File

@ -51,18 +51,9 @@ $_GET['url'] = $_REQUEST['url'] = $url;
$fileName = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $url;
/**
* This code is a very simple wrapper for sending files
* Very quickly pass through references to files
*/
// Pass through references to existing files
if ($url && file_exists($fileName)) {
$fileURL = (dirname($_SERVER['SCRIPT_NAME']) == '/' ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
if (isset($_SERVER['QUERY_STRING'])) {
$fileURL .= '?' . $_SERVER['QUERY_STRING'];
}
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
header("Location: $fileURL");
die();
return false;
}
require_once 'framework/main.php';