初始提交:卡密授权管理系统
This commit is contained in:
commit
59586775c4
202 files changed
+25427
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP内置服务器路由器
|
||||
* 用法: php -S 0.0.0.0:8080 router.php
|
||||
*/
|
||||
|
||||
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
||||
|
||||
// 静态文件直接返回
|
||||
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
|
||||
$filePath = __DIR__ . '/public' . $uri;
|
||||
$ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
|
||||
$mimeTypes = [
|
||||
'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png', 'gif' => 'image/gif',
|
||||
'webp' => 'image/webp', 'svg' => 'image/svg+xml',
|
||||
'css' => 'text/css', 'js' => 'application/javascript',
|
||||
'json' => 'application/json', 'ico' => 'image/x-icon',
|
||||
];
|
||||
header('Content-Type: ' . ($mimeTypes[$ext] ?? 'application/octet-stream'));
|
||||
header('Content-Length: ' . filesize($filePath));
|
||||
header('Cache-Control: public, max-age=31536000');
|
||||
readfile($filePath);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 所有请求统一交由 index.php 处理
|
||||
require_once __DIR__ . '/public/index.php';
|
||||
Reference in new issue
Block a user