php -S 127.0.0.1:81 router.php
주요 해더 설정이 동작안하므로 그걸 임으로 동작하게 하는 라우트 파일 설정함.
------------------------ router.php
<?php
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$file = __DIR__ . urldecode($uri); //$uri;
// var_dump(is_file($file));
// exit($file);
if (is_file($file)) {
$mimeTypes = [
'html' => 'text/html; charset=UTF-8',
'htm' => 'text/html; charset=UTF-8',
'js' => 'application/javascript',
'mjs' => 'application/javascript',
'css' => 'text/css',
'json' => 'application/json',
'xml' => 'application/xml',
'txt' => 'text/plain',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'webp' => 'image/webp',
'svg' => 'image/svg+xml',
'ico' => 'image/x-icon',
'mp3' => 'audio/mpeg',
'wav' => 'audio/wav',
'ogg' => 'audio/ogg',
'mp4' => 'video/mp4',
'webm' => 'video/webm',
'wasm' => 'application/wasm',
'data' => 'application/octet-stream',
];
// Unity Brotli 압축 파일 처리
if (substr($file, -3) === '.br') {
header('Content-Encoding: br');
if (substr($file, -6) === '.js.br') {
header('Content-Type: application/javascript');
}
elseif (substr($file, -8) === '.wasm.br') {
header('Content-Type: application/wasm');
}
elseif (substr($file, -8) === '.data.br') {
header('Content-Type: application/octet-stream');
}
elseif (substr($file, -8) === '.css.br') {
header('Content-Type: text/css');
}
readfile($file);
exit;
}
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (isset($mimeTypes[$ext])) {
header('Content-Type: ' . $mimeTypes[$ext]);
} else {
header('Content-Type: application/octet-stream');
}
readfile($file);
exit;
}
return false;