This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/server.php

16 lines
405 B
PHP
Raw Normal View History

2016-01-17 01:58:31 +00:00
<?php
/*
2016-12-08 23:10:56 +00:00
* mod_rewrite emulator for php's built in server
2016-01-17 01:58:31 +00:00
*/
2016-02-04 20:56:40 +00:00
// Decode and parse the request uri
2016-01-17 01:58:31 +00:00
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
2016-02-04 20:56:40 +00:00
// Check if the file exist in the public directory and if it does serve it.
2016-01-17 01:58:31 +00:00
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
return false;
}
2016-02-04 20:56:40 +00:00
// Otherwise include the router
2016-01-17 01:58:31 +00:00
require_once __DIR__ . '/public/index.php';