diff --git a/app/router.php b/app/router.php index 91b6d75..a8b4ef8 100644 --- a/app/router.php +++ b/app/router.php @@ -13,6 +13,14 @@ $requestUri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH) ?: '/'; $hasTrailingSlash = str_ends_with($requestUri, '/') && $requestUri !== '/'; $requestPath = trim($requestUri, '/'); +// Check for assets in /custom/assets/ served at root level (before language extraction) +$assetPath = dirname(__DIR__) . '/custom/assets/' . $requestPath; +if (file_exists($assetPath) && is_file($assetPath)) { + header('Content-Type: ' . (mime_content_type($assetPath) ?: 'application/octet-stream')); + readfile($assetPath); + exit; +} + // Extract language from URL $currentLang = $defaultLang; $pathParts = explode('/', $requestPath); @@ -351,26 +359,6 @@ function renderFile(string $filePath): void { exit; } -// Check for assets in /custom/assets/ served at root level -$assetPath = dirname(__DIR__) . '/custom/assets/' . $requestPath; -if (file_exists($assetPath) && is_file($assetPath)) { - header('Content-Type: ' . (mime_content_type($assetPath) ?: 'application/octet-stream')); - readfile($assetPath); - exit; -} - -// Check for static files in content directory -$contentFilePath = rtrim($contentDir, '/') . '/' . ltrim($requestPath, '/'); -if (file_exists($contentFilePath) && is_file($contentFilePath)) { - $ext = pathinfo($contentFilePath, PATHINFO_EXTENSION); - // Only serve non-PHP/non-HTML/non-MD files as static assets - if (!in_array($ext, ['php', 'html', 'md'])) { - header('Content-Type: ' . (mime_content_type($contentFilePath) ?: 'application/octet-stream')); - readfile($contentFilePath); - exit; - } -} - // Handle frontpage if (empty($requestPath)) { // Try language-specific frontpage first, then default