From 8ec36616487c9497e7c9f55561e723da2ccc5e0c Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 14 Jan 2022 06:32:57 +0100 Subject: [PATCH] sitemap: strip main from the end --- sitemap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sitemap.php b/sitemap.php index 19d3c0d..da6cc40 100644 --- a/sitemap.php +++ b/sitemap.php @@ -16,10 +16,10 @@ $iterator = new \RecursiveIteratorIterator($filter); $isHttps = isHttps(); foreach ($iterator as $info) { if ($info->isFile()) { - [, $year, $pages, $page] = explode('/', $info->getPathname(), 4); + [, $year,, $page] = explode('/', $info->getPathname(), 4); if (str_ends_with($page, '.pg') && !str_starts_with($page, 'cs/error/') && !str_starts_with($page, 'en/error/') && !str_starts_with($page, 'de/error/')) { $file = substr($page, 0, -3); - $file = str_replace('/pages', '', $file); + $file = preg_replace('(/main$)', '/', $file); echo ($isHttps ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . $year . '/' . $file . "\n"; } }