Google将我的站点地图编入索引为HTML

时间:2017-06-17 13:15:40

标签: php xml sitemap

我找不到解决方案,我也曾在谷歌论坛上询问,但他们还没有解决问题。

随着我的网页每天都在变化,我正在使用PHP生成动态站点地图。我遵循的过程:

1.-使用以下代码创建名为sitemap.php的文件:

<?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.-在.htaccess文件中,我插入此代码:

RewriteRule ^sitemap\.xml$ sitemap.php [L]

3.-最后,在robots.txt中提交此其他代码:

Sitemap: http://www.laxtore.com/sitemap.php

但每当我在Google上传文件时,它都会将其识别为HTML文件,即使我转到文件目录,XML也能正确生成。您可以在这里查看:http://www.laxtore.com/sitemap.php

由于声誉,我无法分享图片(我是新来的)。

¿有办法解决这个问题吗?我也尝试使用在线生成的xml,即使使用该文件,我也收到相同的错误

修改

谷歌支持告诉我,我不能使用这种结构:

<?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>

但是他们在网站上放置的例子是:https://support.google.com/news/publisher/answer/74288?hl=es

编辑2:

尝试修改该结构并使用:

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";

我一直有同样的问题。我想这可能是由于www.重定向或其他原因造成的。在我发送站点地图时,在Google网站站长工具中,网址为http://laxtore.com/sitemap.php,但要访问站点地图,我必须引入http://www.laxtore.com/sitemap.php,否则不会收取任何费用。

1 个答案:

答案 0 :(得分:0)

只是尝试向Google发送您的XML-Sitemap,我认为Google不会将Sitemaps识别为XML,如果它们不以.xml结尾。 live link

您尝试过这种结构:

{{1}}

是Google新闻的站点地图,只能由发布商使用。

你也应该有一个www。如果您将此作为您的网站网址,请使用搜索控制台帐户。