1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Add a router file for the built-in webserver

Usage: php -S localhost:8080 .router.php
This commit is contained in:
Hannes Magnusson
2013-11-20 15:06:45 -08:00
parent f33391c3ce
commit 8e9b03fce7

15
.router.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
$_SERVER["SERVER_ADDR"] = $_SERVER["HTTP_HOST"];
$filename = isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : $_SERVER["SCRIPT_NAME"];
$afilename = $_SERVER["DOCUMENT_ROOT"] . $filename;
$afilename = realpath($afilename);
$len = strlen($_SERVER["DOCUMENT_ROOT"]);
if (strncmp($_SERVER["DOCUMENT_ROOT"], $afilename, $len) == 0) {
if (file_exists($afilename)) {
return false;
}
}
include_once "error.php";