【问题标题】:Escaped # in URLs, sitemap and handling by Google crawler在 URL、站点地图和 Google 爬虫处理中转义 #
【发布时间】:2018-07-23 05:53:30
【问题描述】:

我们有大量的 URL,其中一些包含哈希字符。哈希 不是 表示片段,而是 URL 路径的一部分,所以我们通过 %23 对哈希进行转义,例如

http://example.com/example%231
http://example.com/another-example%232
…

我们的sitemap.xml 列出这些网址如下:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>http://example.com/example%231</loc>
  </url>
  <url>
    <loc>http://example.com/another-example%232</loc>
  </url>
  <!-- and so on … -->
</urlset>

现在,Google Search Console 报告以下网址的 404 错误:

http://example.com/example
http://example.com/another-example

请注意,%23 之后的字符串已被删除。如果站点地图包含例如,我会理解这种行为。 http://example.com/example#1,但我们有意对哈希进行编码 (http://example.com/example%231)。

有什么我可能误解的地方,或者sitemap.xml内有什么特殊的转义规则吗?

【问题讨论】:

    标签: google-search-console xml-sitemap url-fragment


    【解决方案1】:

    谷歌don't want you to use fragments in that way。然而,他们仍然将它们视为实际的片段标识符,例如从搜索结果直接链接到维基百科文章的多个子标题。

    因此,Google 可能会将您的哈希值解释为片段 ID,因此会将它们从您的 URL 中删除,从而得到 404。

    XML Sitemaps follow 通常转义设置在RSC 3986 中。关于Google's deprecated 使用!# Ajax URL 的一些历史可能是有用的背景。

    【讨论】:

      猜你喜欢
      • 2014-09-19
      • 2012-01-29
      • 1970-01-01
      • 2011-05-22
      • 2019-11-07
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多