如何通过301重定向移动URL,并保留页面的Facebook点赞和Open Graph信息? [英] How can I move a URL via 301 redirect and retain the page's Facebook likes and Open Graph information?

查看:72
本文介绍了如何通过301重定向移动URL,并保留页面的Facebook点赞和Open Graph信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解og:url元标记是打开图中资源的规范网址.

I understand the og:url meta tag is the canonical url for the resource in the open graph.

如果我希望支持该资源的301重定向,同时保留其在打开图中的位置,我可以使用哪些策略?我不想失去我的喜欢,因为我已经更改了网址.

What strategies can I use if I wish to support 301 redirecting of the resource, while preserving its place in the open graph? I don't want to lose my likes because i've changed the URLs.

做到这一点的最佳方法是存储内容的原始url,并进行引用吗?还有其他应对策略吗?

Is the best way to do this to store the original url of the content, and refer to that? Are there any other strategies for dealing with this?

为了澄清-我有页面:

/page1og:urlhttp://www.example.com/page1

我现在想将其移至 /page2,使用301重定向到http://www.example.com/page2

I now want to move it to /page2, using a 301 redirect to http://www.example.com/page2

除了将og:url元设置为/page1之外,我是否有其他选择来避免失去喜欢和评论?

Do I have any options to avoid losing the likes and comments other than setting the og:url meta to /page1?

推荐答案

简短答案,不能.

在Facebook一侧创建对象后,其在Facebook图形中的URL是固定的-Likes和Comments与该URL和对象相关联;您需要该URL可供Facebook的抓取工具访问,以便将来维护该对象. (请注意,变得无法访问的对象不一定会将其从Facebook删除,但实际上您应该重新开始)

Once the object has been created on Facebook's side its URL in Facebook's graph is fixed - the Likes and Comments are associated with that URL and object; you need that URL to be accessible by Facebook's crawler in order to maintain that object in the future. (note that the object becoming inaccessible doesn't necessarily remove it from Facebook, but effectively you'd be starting over)

我通常在这里推荐的是(带有示例http://www.example.com/oldurlhttp://www.example.com/newurl):

What I usually recommend here is (with examples http://www.example.com/oldurl and http://www.example.com/newurl):

  • 在/newpage上,保持og:url标记指向/oldurl
  • 添加从/oldurl到/newurl的HTTP 301重定向
    • 从此重定向中豁免Facebook搜寻器
    • 如果请求来自Facebook搜寻器,则继续为http://www.example.com/oldurl上的页面提供元标记.
    • 无需将任何实际内容返回给爬虫,只需一个带有适当标签的简单HTML页面
    • On /newpage, keep the og:url tag pointing to /oldurl
    • Add a HTTP 301 redirect from /oldurl to /newurl
      • Exempt the Facebook crawler from this redirect
      • Continue to serve the meta tags for the page on http://www.example.com/oldurl if the request comes from the Facebook crawler.
      • No need to return any actual content to the crawler, just a simple HTML page with the appropriate tags

      因此:

      1. 单击Facebook上对象的现有实例后,将通过重定向将用户带到正确的(新)页面
      2. (新)页面上的赞"按钮仍会产生正确对象的赞(但在旧URL处)

      如果要移动大量URL或完全重写URL方案,则应为新文章/产品/等使用新的URL,但是如果要保留喜欢的链接,则需要保留重定向,对旧内容的评论等.

      If you're moving a lot of URLs around or completely rewriting your URL scheme you should use the new URLs for new articles/products/etc, but you'll need to keep the redirect in place if you want to retain likes, comments, etc on the older content.

      这包括您要更改的域.

      这里唯一的问题是在代码中的某个位置维护旧的URL->新的URL映射,但这在技术上并不困难,只是将来需要维护的另一件事.

      The only problem here is maintaining the old URL -> new URL mapping somewhere in your code, but it's not technically difficult, just an additional thing to maintain in the future.

      顺便说一句,Facebook搜寻器UA当前为facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)

      BTW, The Facebook crawler UA is currently facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)

      这篇关于如何通过301重定向移动URL,并保留页面的Facebook点赞和Open Graph信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆