I cannot find the solution for this, I have also asked on Google Forums but they haven't solved the problem.
As my webpage changes everyday, I am generating a dynamic sitemap with PHP. The process I have followed for this:
1.- Create a file named sitemap.php
with this code:
<?php
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'
xmlns:news='http://www.google.com/schemas/sitemap-news/0.9'>";
require 'admin/config.php';
require 'funciones.php';
try {
$conexion = new PDO($bd_config['dbname'], $bd_config['usuario'], $bd_config['password'] );
} catch (PDOException $e) {
header ('Location: error.php');
echo "ERROR: ".$e->getMessage();
die();
}
//CODE
echo "</urlset>\n";
?>
2.- In the .htaccess
file I insert this code:
RewriteRule ^sitemap\.xml$ sitemap.php [L]
3.- And finally, in robots.txt
file this other code:
Sitemap: http://www.laxtore.com/sitemap.php
But whenever I upload the file in Google, it recognizes it as an HTML file, even if I go to the file directory, the XML is generating correctly. Here you can check it: http://www.laxtore.com/sitemap.php
I cannot share an image yet due to the reputation (I´m new here).
¿Is there a way to solve this? I have also tried to use an xml generated online, and even with that file I receive the same error
EDIT:
Google support has told me that I cannot use this structure:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<url>
<loc>http://www.example.org/business/article55.html</loc>
<news:news>
<news:publication>
<news:name>The Example Times</news:name>
<news:language>en</news:language>
</news:publication>
<news:genres>PressRelease, Blog</news:genres>
<news:publication_date>2008-12-23</news:publication_date>
<news:title>Companies A, B in Merger Talks</news:title>
<news:keywords>business, merger, acquisition, A, B</news:keywords>
<news:stock_tickers>NASDAQ:A, NASDAQ:B</news:stock_tickers>
</news:news>
</url>
</urlset>
But is the one they put as example on its site: https://support.google.com/news/publisher/answer/74288?hl=es
EDIT 2:
After trying modifying that structure and using just:
echo "<url>\n";
echo "<loc>http://www.laXtore.com/noticia/" . $articulo['ID'] . "/" . limpia_url($articulo['titulo']) . "/</loc>\n";
echo "<changefreq>daily</changefreq>\n";
echo "<priority>1</priority>\n";
echo "</url>\n";
I keep having the same problem. I am thinking that it could be due to www.
redirect or whatever. In Google Webmaster Tool when I send the sitemap, the URL is http://laxtore.com/sitemap.php
, but to access to the sitemap I have to introduce http://www.laxtore.com/sitemap.php
, otherwise nothing is charged.