大网数据广告活动
网站运营与故障问答

Changing sitemap.xml and robots.txt after moving from http to https

· 52CE 我爱测

I am migrating a website from http to https entirely, all http urls will have 301 redirects to their https counterparts. From https://support.google.com/webmasters/answer/6033049 We reference our HTTP sitemaps in robots.txt. Shou…

问题原文

原帖链接 · Vilial · CC BY-SA 3.0

I am migrating a website from http to https entirely, all http urls will have 301 redirects to their https counterparts.

From https://support.google.com/webmasters/answer/6033049

We reference our HTTP sitemaps in robots.txt. Should we update the robots.txt to include our new HTTPS sitemaps?

We recommend separate robots.txt files for HTTP and HTTPS, pointing to separate sitemap files for HTTP and HTTPS. We also recommend listing a specific URL in only one sitemap file.

What URLs should our sitemaps list if we have redirects (from HTTP to HTTPS or the reverse)?

List all HTTP URLs in your HTTP sitemap, and all HTTPS URLs in your HTTPS sitemap, regardless of redirects when the user visits the page. Having pages listed in your sitemap regardless of redirects will help search engines discover the new URLs faster.

From this I assume the following should be correct:

  1. http://example.com/robots.txt should exist and have a Sitemap directive pointing to the old sitemap.xml with http urls.

  2. https://example.com/robots.txt should exist and have a Sitemap directive pointing to the new sitemap.xml (maybe called something like sitemap_https.xml) with https urls that are same as the old ones but have https instead of http.

But further reading of google guidelines shows another approach that contradicts this one (or maybe I just misunderstood something?)

From answer https://support.google.com/webmasters/answer/6033080:

Update your robots.txt files:

  • On the source site, remove all robots.txt directives. This allows Googlebot to discover all redirects to the new site and update our index.

  • On the destination site, make sure the robots.txt file allows all crawling. This includes crawling of images, CSS, JavaScript, and other page assets, apart from the URLs you are certain you do not want crawled.

On the destination site, submit the two sitemaps you prepared previously containing the old and new URLs. This helps our crawlers discover the redirects from the old URLs to the new URLs, and facilitates the site move.

This is how I understand this approach:

  1. http robots.txt should exist and have no directives in it (be empty).

  2. https robots.txt should exist and have two Sitemap directives, one to old sitemap.xml and another to new sitemap_https.xml

Maybe "submit the two sitemaps" means something different from listing them in robots.txt? Like using the Search Console or something? It doesn't clarify, just "submit"...

Besides, point 1 of this approach contradicts point 1 of the first approach.

社区高分解答

原帖链接 · DhruvPathak · CC BY-SA 3.0

The first approach is the correct one. We successfully migrated a high traffic and rankings website from HTTP to HTTPS completely. The approach based on Google guidelines was:

  1. All HTTP URLs do a 301 permanent redirect to HTTPS.

  2. http://www.example.com/robots.txt would redirect to the HTTPS version https://www.example.com/robots.txt

  3. The new sitemap shall have all HTTPS links.

Here is a good post about this from Google :

https://plus.google.com/+JohnMueller/posts/PY1xCWbeDVC

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。