Files
novaconium/public/router.php
T
code fbd4e92e9f Replace v1 with v2 codebase
Full rewrite: swap out the v1 framework (src/, controllers/, views/,
twig/, sass/, skeleton/) for the working v2 codebase from phpproject
(App/, novaconium/, public/).
2026-07-14 01:58:25 +00:00

24 lines
662 B
PHP

<?php
// Dev-only router for `php -S`, mimicking the .htaccess rules for local testing.
// Not used in production (Apache reads .htaccess directly).
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if ($uri !== '/' && str_ends_with($uri, '/')) {
header('Location: ' . rtrim($uri, '/'), true, 301);
exit;
}
$file = __DIR__ . $uri;
if ($uri !== '/' && (is_file($file) || is_dir($file))) {
return false; // let the built-in server handle real files/dirs (css, cache)
}
$cacheFile = __DIR__ . '/cache' . $uri . '/index.html';
if (is_file($cacheFile)) {
readfile($cacheFile);
return true;
}
require __DIR__ . '/index.php';