search-engine - 站点地图索引和 robots.txt 引用 .gz 文件

标签 search-engine sitemap robots.txt

对于一个网站,我的站点地图索引文件和我所有的站点地图都被 gzip 压缩并具有如下名称(SiteMapIndex.xml.gz、SiteMap1.xml.gz、SiteMap2.xml.gz),robots.txt 应该文件和 SiteMapIndex.xml 文件引用了 gzip 文件名或非 gzip 文件名?

例子 - robots.txt 的内容应该是这样的吗? -

Sitemap: http://www.mysite.com/SiteMapIndex.xml.gz

或者像这样(没有 .gz)?

Sitemap: http://www.mysite.com/SiteMapIndex.xml

SiteMapIndex.xml 的内容应该是这样的吗? -

...
<sitemap>
  <loc>http://www.mysite.com/SiteMap1.xml.gz</loc>
  <lastmod>2013-08-20</lastmod>
</sitemap>
<sitemap>
  <loc>http://www.mysite.com/SiteMap2.xml.gz</loc>
  <lastmod>2013-08-20</lastmod>
</sitemap>
...

还是这个(没有 .gz)? -

...
<sitemap>
  <loc>http://www.mysite.com/SiteMap1.xml</loc>
  <lastmod>2013-08-20</lastmod>
</sitemap>
<sitemap>
  <loc>http://www.mysite.com/SiteMap2.xml</loc>
  <lastmod>2013-08-20</lastmod>
</sitemap>
...

最佳答案

如果您希望机器人读取 .gz 文件,请将 .gz 名称放入索引中。即:

<sitemap>
  <loc>http://www.mysite.com/SiteMap1.xml.gz</loc>
  <lastmod>2013-08-20</lastmod>
</sitemap>
<sitemap>
  <loc>http://www.mysite.com/SiteMap2.xml.gz</loc>
  <lastmod>2013-08-20</lastmod>
</sitemap>

参见 Using Sitemap Index Files .

您的 robots.txt 文件也是如此:输入 gzip 文件的名称。

参见 Specifying the Sitemap location in your robots.txt file

关于search-engine - 站点地图索引和 robots.txt 引用 .gz 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18340992/

相关文章:

python - 如何从ODP中准确提取信息?

php - 我将如何进行自定义 Whois 查找

php - 如何在使用 php 和 mysql 的同时为我们自己的动态站点创建 rss 提要 (.xml)?

.htaccess - htaccess 从 https 中排除 sitemap.xml 和 robots.txt

mysql - 通过 Linux 命令行连接到 SphinxQL

java - Lucene搜索引擎中使用自建方法

xml - 谷歌附加链接

asp.net - 搜索引擎站点地图 Asp.Net

coldfusion - Robots.txt 和 Coldfusion

node.js - "Lighthouse was unable to download a robots.txt file"尽管文件可访问