I create the page http://omenorpreco.com/sitemap_index.xml for google read and identify all my pages.
but, when access this page, the XML dont open in xml mode.
if i view source of this page, copy and past in a file on my desktop and open in brownser, this file open correctly
What is wrong?
<?php
echo "<?xml version='1.0' encoding='UTF-8'?>";?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
header("Content-Type: application/xml; charset=UTF-8");
$sql = "SELECT ceil(count(*)/5000) as total FROM `produto_price`";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
?>
<sitemap>
<loc>http://omenorpreco.com/sitemap-categoria.xml</loc>
<lastmod><?php echo date('Y-m-d'); ?></lastmod>
</sitemap>
<?php
for($i = 1; $i <= $row['total']; $i++) : ?>
<sitemap>
<loc>http://omenorpreco.com/sitemap-<?php echo $i ; ?>.xml</loc>
<lastmod><?php echo date('Y-m-d'); ?></lastmod>
</sitemap>
<?php
endfor
?>
</sitemapindex>
My .htaccess file redirect to url_amigavel.php
And url_amigavel.php include the file sitemap_index.php
Try this
<?php
header("Content-Type: application/xml; charset=UTF-8");
echo "<?xml version='1.0' encoding='UTF-8'?>";
$sql = "SELECT ceil(count(*)/5000) as total FROM `produto_price`";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://omenorpreco.com/sitemap-categoria.xml</loc>
<lastmod><?php echo date('Y-m-d'); ?></lastmod>
</sitemap>
<?php for($i = 1; $i <= $row['total']; $i++): ?>
<sitemap>
<loc>http://omenorpreco.com/sitemap-<?php echo $i ; ?>.xml</loc>
<lastmod><?php echo date('Y-m-d'); ?></lastmod>
</sitemap>
<?php endfor; ?>
</sitemapindex>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.