<?php

$uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';

// If this is API/health, boot Laravel; otherwise serve landing site
if (preg_match('#^/(api|up)(/|$)#', $uri)) {
    require __DIR__ . '/bp_laravel.php';
    exit;
}

// Serve landing
$landingPhp = __DIR__ . '/landing/index.php';
$landingHtml = __DIR__ . '/landing/index.html';

if (file_exists($landingPhp)) {
    require $landingPhp;
    exit;
}
if (file_exists($landingHtml)) {
    readfile($landingHtml);
    exit;
}

http_response_code(200);
echo "Landing not found.";