26 lines
999 B
PHP
26 lines
999 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/** Dynamische sitemap.xml (Domain wird automatisch erkannt). */
|
|
final class SitemapController extends Controller
|
|
{
|
|
public function xml(): void
|
|
{
|
|
header('Content-Type: application/xml; charset=utf-8');
|
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
$base = $scheme . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost');
|
|
|
|
// Nur indexierbare Inhaltsseiten (App-Seiten sind noindex)
|
|
$paths = [
|
|
'/', '/regeln', '/spielanleitung', '/strategie', '/spielvarianten',
|
|
'/faq', '/partyspiele', '/datenschutz', '/impressum',
|
|
];
|
|
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
|
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
|
foreach ($paths as $p) {
|
|
echo ' <url><loc>' . htmlspecialchars($base . $p, ENT_QUOTES) . '</loc></url>' . "\n";
|
|
}
|
|
echo '</urlset>' . "\n";
|
|
}
|
|
}
|