17 lines
363 B
PHP
17 lines
363 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Router script for PHP built-in server
|
||
|
|
* Usage: php -S localhost:8000 router.php
|
||
|
|
*/
|
||
|
|
|
||
|
|
// If the request is for a file that exists, serve it
|
||
|
|
$file = __DIR__ . $_SERVER['REQUEST_URI'];
|
||
|
|
if (file_exists($file) && is_file($file) && $_SERVER['REQUEST_URI'] !== '/') {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Otherwise, route to index.php
|
||
|
|
require __DIR__ . '/index.php';
|
||
|
|
|