= filemtime($file)) ) { http_response_code(304); exit; } header('ETag: ' . $etag); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT'); header('Cache-Control: public, max-age=86400'); header('X-Content-Type-Options: nosniff'); $mimeMap = [ 'js' => 'application/javascript', 'css' => 'text/css', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'svg' => 'image/svg+xml', 'ico' => 'image/x-icon', 'webp' => 'image/webp', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'ttf' => 'font/ttf', 'eot' => 'application/vnd.ms-fontobject', 'otf' => 'font/otf', 'map' => 'application/json', 'json' => 'application/json', 'xml' => 'application/xml', 'pdf' => 'application/pdf', 'zip' => 'application/zip', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'wav' => 'audio/wav', 'avi' => 'video/x-msvideo', ]; header('Content-Type: ' . ($mimeMap[$ext] ?? 'application/octet-stream')); readfile($file); exit; } // PHP、HTML 等文件交给 PHP 内置服务器处理 return false; } else { require __DIR__ . "/index.php"; }