<?php
/**
 * Dynamic Sitemap Index
 * Served via .htaccess rewrite: sitemap.xml → sitemap_index.php
 * Domain auto-detected — works on any host/domain.
 */
header("Content-Type: application/xml; charset=utf-8");

$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host     = $_SERVER['HTTP_HOST'];
$base     = $protocol . '://' . $host;

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc><?= $base ?>/sitemap.php</loc>
        <lastmod><?= date('Y-m-d') ?></lastmod>
    </sitemap>
</sitemapindex>
