Update -> refactor and optimize UI , code ,...
This commit is contained in:
21
public/router.php
Normal file
21
public/router.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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';
|
||||
Reference in New Issue
Block a user