diff --git a/index.php b/index.php index e0eebf8..3e03a20 100644 --- a/index.php +++ b/index.php @@ -20,7 +20,8 @@ if (!isLoggedIn()) { if($routerRequest["site_name"] == "sitemap.xml") { require "lib/sitemap.php"; - return generateSitemap(); + echo generateSitemap(); + exit(); } if ($routerRequest["type"] == "api") { diff --git a/lib/router.php b/lib/router.php index 2a74b0d..5814c00 100644 --- a/lib/router.php +++ b/lib/router.php @@ -12,15 +12,16 @@ function initRouter(): array $request_uri = array_slice($request_uri, -3, 3); - $routerRequest["site_name"] = basename($request_uri[1]); - $routerRequest["page_name"] = basename($request_uri[2]); - if (empty($routerRequest["site_name"])) { - $routerRequest["site_name"] = $routerConfig["default_site"]; + $routerRequest["site_name"] = $routerConfig["default_site"]; + $routerRequest["page_name"] = $routerConfig["default_page"]; + + if(count($request_uri > 2)){ + $routerRequest["page_name"] = basename($request_uri[2]); } + if(count($request_uri) > 1){ + $routerRequest["site_name"] = basename($request_uri[1]); - if (empty($routerRequest["page_name"])) { - $routerRequest["page_name"] = $routerConfig["default_page"]; } if($_SERVER["REQUEST_METHOD"] == "POST"){