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:
15
.router.php
Normal file
15
.router.php
Normal 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";
|
||||
|
||||
Reference in New Issue
Block a user