站点地图中的多个 url 位置

Dor*_*rad 4 sitemap configuration web

我更改了网站中一些重要页面的网址。

为了保持向后兼容性并避免破坏指向这些页面并且已经展开的链接,原始地址仍然有效。所以有两个地址到完全相同的页面。

它应该如何在站点地图中定义?

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>http://www.example.com/old_address1</loc>
      <loc>http://www.example.com/new_address1</loc>
   </url>
   <url>
      <loc>http://www.example.com/old_address2</loc>
      <loc>http://www.example.com/new_address2</loc>
   </url>
</urlset> 
Run Code Online (Sandbox Code Playgroud)

这是正确的吗?

cau*_*chy 5

总结一下您的问题,您已经创建了一个新端点,您可以在其中为用户提供服务。但是您不希望具有旧 URL 的用户登陆一个孤立的页面。为了解决这个问题,您在服务器上托管了这两个 URL。但是现在,您如何告诉 GoogleBot 两者是同一页面?

根据您迄今为止的尝试,我假设您更喜欢使用站点地图文件的解决方案。

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>http://www.example.com/new_address1</loc>
        <xhtml:link rel="canonical" href="http://www.example.com/old_address1" />
    </url>
    <url>
        <loc>http://www.example.com/new_address2</loc>
        <xhtml:link rel="canonical" href="http://www.example.com/old_address2" />
    </url>
</urlset>
Run Code Online (Sandbox Code Playgroud)

还有其他方法可以实现这一点。一种方法是使用页面本身部分中的rel="canonical"链接标记将旧的指定为规范 URL HEAD

<link rel="canonical" href="http://www.example.com/old_address2" />
Run Code Online (Sandbox Code Playgroud)

作为参考,请查看以下链接:

  1. 合并重复的 URL

  2. 单独的网址