sitemap: strip main from the end

This commit is contained in:
2022-01-14 06:32:57 +01:00
parent 4af70fef6d
commit 8ec3661648

View File

@@ -16,10 +16,10 @@ $iterator = new \RecursiveIteratorIterator($filter);
$isHttps = isHttps(); $isHttps = isHttps();
foreach ($iterator as $info) { foreach ($iterator as $info) {
if ($info->isFile()) { 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/')) { 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 = substr($page, 0, -3);
$file = str_replace('/pages', '', $file); $file = preg_replace('(/main$)', '/', $file);
echo ($isHttps ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . $year . '/' . $file . "\n"; echo ($isHttps ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . $year . '/' . $file . "\n";
} }
} }