I've created a dynamic sitemap and linked it using a sitemapindex.(pasted all the code below).
Whenever I try to add the sitemapindex to bing or google for indexing google tells me that it is a correct sitemap but it tells me that my sitemap has an unsopported file format.
I store 10000 urls per sitemap.
These two lines are in my htaccess for rewriting php to xml:
RewriteRule ^sitemap_xml\.xml$ sitemap_xml.php [L]
RewriteRule ^sitemap_xml$ sitemap_xml.php [L]
sitemap.xml link
<?xml version="1.0"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=site</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=0</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=1</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=2</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=3</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=4</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=5</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=6</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=7</loc>
</sitemap>
<sitemap>
<loc>https://www.kentekentje.nl/sitemap_xml.xml?cat=kenteken&t=nul&o=8</loc>
</sitemap>
</sitemapindex>
sitemap_xml.php link
header("content-type: application/xml; charset=UTF-8");
$doc = new DomDocument('1.0', 'UTF-8');
if (isset($_GET['cat']) && !empty($_GET['cat'])) {
$lastmod = date("Y-m-d") . "T" . date("H:i:s") . "+00:00";
if ($_GET['cat'] == "kenteken" && isset($_GET['t']) && !empty($_GET['t'])) {
if (isset($_GET['t']) && isset($_GET['o']) && is_numeric($_GET['o'])) {
$exec = false;
if (preg_match('/^[A-Z0-9]+$/', $_GET['t']) && $_GET['t'] != "C" && $_GET['t'] != "I" && $_GET['t'] != "Q") {
$exec = true;
$t = $_GET['t'];
} elseif ($_GET['t'] == "nul") {
$exec = true;
$t = "0";
}
if ($exec === true) {
$limit = 10000;
$offset = $_GET['o'] * 10000;
$kentekenlist_q = $mysqli->prepare("SELECT kenteken FROM RDW_" . $t . " LIMIT " . $limit . " OFFSET " . $offset);
$kentekenlist_q->execute();
$kentekenlist = $kentekenlist_q->get_result();
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
. '<urlset/>');
$xml->addAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
//echo $_GET['o'];
while ($i = $kentekenlist->fetch_assoc()) {
$url = $xml->addChild("url");
$url->addChild("loc", $weburl . "kenteken/KL-45-RS/");
$url->addChild("lastmod", $lastmod);
$url->addChild("changefreq", "yearly");
$url->addChild("priority", "0.4");
}
echo $xml->asXML();
}
}
}
}