$host = $_SERVER['HTTP_HOST']; $parts = explode('.', $host); $subdomain = $parts[0]; $sitePath = __DIR__ . "/sites/$subdomain"; if (is_dir($sitePath)) { require $sitePath . "/index.php"; } else { echo "Site not found"; }