if ($currentDir && strpos($path, $currentDir) === 0) { $path = substr($path, strlen($currentDir)); } $path = ltrim($path, '/'); // Handle static files (CSS, JS, images) $filePath = __DIR__ . '/' . $path; if (file_exists($filePath) && is_file($filePath)) { // Set correct MIME type based on extension $extension = pathinfo($filePath, PATHINFO_EXTENSION); switch (strtolower($extension)) { case 'css': header('Content-Type: text/css'); break; case 'js': header('Content-Type: application/javascript'); break; case 'json': header('Content-Type: application/json'); break; case 'png': header('Content-Type: image/png'); break; case 'jpg': case 'jpeg': header('Content-Type: image/jpeg'); break; case 'gif': header('Content-Type: image/gif'); break; case 'svg': header('Content-Type: image/svg+xml'); break; case 'ico': header('Content-Type: image/x-icon'); break; case 'woff': header('Content-Type: font/woff'); break; case 'woff2': header('Content-Type: font/woff2'); break; default: // Let server handle other files break; } // Output file content readfile($filePath); exit(); } // Handle API requests if (strpos($path, 'api/') === 0) { $apiPath = __DIR__ . '/' . $path; if (file_exists($apiPath)) { include $apiPath; exit(); } } // For all other requests, serve the React app header('Content-Type: text/html; charset=UTF-8'); readfile(__DIR__ . '/index.html'); exit(); ?>