22 lines
496 B
PHP
22 lines
496 B
PHP
<?php
|
|
$uri = $_SERVER['REQUEST_URI'];
|
|
$path = parse_url($uri, PHP_URL_PATH);
|
|
|
|
// Strip trailing slash
|
|
$path = rtrim($path, '/') ?: '/';
|
|
|
|
// Route: /view/{id}
|
|
if (preg_match('#^/view/([a-f0-9]+)$#i', $path, $m)) {
|
|
$_GET['id'] = $m[1];
|
|
require __DIR__ . '/view.php';
|
|
exit;
|
|
}
|
|
|
|
// Route: static assets
|
|
if (preg_match('#\.(css|js|png|jpg|ico|svg|woff2?)$#', $path)) {
|
|
return false; // let PHP built-in server serve the file
|
|
}
|
|
|
|
// Route: / or /index.php
|
|
require __DIR__ . '/index.php';
|