Switching from HTTP to HTTPS, lost all Facebook “Likes” count

点点圈 提交于 2019-12-03 08:48:26

问题


I have one site switch to https://www.example.com since two months ago, and it loses all 'likes' count.

Even I use the facebook fql query, it now has the same count between the http:// and https:/

Anyone knows whether it is a facebook bug? or there is a workaround solution for retrieving the old like counts?

Great appreciation would be delivered for your help.


回答1:


Typically Facebook likes are linked to a URL. Even a single character change will lose Facebook likes.

Here is a link on Facebook

https://developers.facebook.com/docs/plugins/faqs#moving-urls

Go to the bottom of the page and find this section How do I move a page to a different URL? - can I migrate the number of likes to the new page location?

<meta property="og:url" content="https://example.com/old-url" />

You will need to instruct the facebook crawler to re-scrape your url for the changes to take effect:

https://developers.facebook.com/tools/debug/sharing

That should be a solution to your problem.




回答2:


The steps that should be followed in order not to lose Facebook likes when migrating HTTP to HTTPS are:

1. Use 301 Redirect on web page for HTTP to HTTPS.

2. Add og:url tag on the HEAD section for http://www.example.com

<meta property="og:url" content="http://www.example.com" />

3. Modify Facebook code to count HTTPS likes on page:

<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.example.com&amp;width&amp;layout=box_count&amp;action=like&amp;show_faces=false&amp;share=true&amp;height=65" scrolling="no" frameborder="0" allowTransparency="true"></iframe>

or

<div class="fb-like" data-href="https://www.example.com" data-layout="standard" 
      data-action="like" data-show-faces="true"</div>

4. Go to Sharing Debugger on Facebook website.
You must be log on Facebook in order to use it.

Enter https://www.example.com and press Debug button.

5. If no other likes are on the HTTPS version of the page, the following info appears:

Press Fetch new information button.

6. If by any chance there are any likes for the HTTPS version of the page or the Facebook crawler already visited your page, the following info appears:

Press Scrape Again button.

7. Refresh your web page and the Facebook likes should be present.

More information about how the Facebook crawler works can be found at:
https://developers.facebook.com/docs/sharing/webmasters/crawler




回答3:


I use iframe-version of FB Like button code and this worked fine in my case:

  1. Redirect pages in .htaccess to HTTPS version for all, except Facebook Bot (code for Apache 2.4):

    RewriteCond %{HTTP_USER_AGENT} !^facebookexternalhit
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,QSA,L,NE]
    
  2. Use HTTP version of URL in og:url tag (this is rendered in HTTP and also HTTPS version of page):

    <meta property='og:url' content="http://my-domain.com/xyz">

  3. Use HTTPS version of URL in canonical tag (this is for "the rest of the world" except Facebook):

    <link rel="canonical" href="https://my-domain.com/xyz">

  4. Use HTTP version of URL in iframe with facebook like button:

    <iframe scrolling="no" frameborder="0" allowtransparency="true" src="https://www.facebook.com/plugins/like.php?layout=button_count&amp;show_faces=false&amp;width=200&amp;action=like&amp;colorscheme=&amp;height=21&amp;href=http%3A%2F%2Fmy-domain%2Fxyz"></iframe>

This is the way how can you preserve all likes on all pages and also have full-HTTPS traffic.

I recommend to use this trick only for "old pages". New pages could use new address with HTTPS everywhere (they don't have "old likes" on "old URL").

The benefit compared to other solutions is, that there is no need to recrawl all pages by FB Bot. Likes are preserved immediately (if you do not use HTTP URL in iframe, it also works, but you need to recrawl every page to see old likes on the new page).




回答4:


You can recover your social media shares. For G+ it's easy as you have to modify just the Google+ sharing buttons so that you will share the URL on http and not on https. when it comes to fb you need to:

  1. use the debug interface to check out your urls
  2. click on "scrape again" - all your social counts will get to zero
  3. update rel = canonical and make the http version the preferred one but just for FB crawlers
  4. identify FB crawler ; here depends on what you are using; exact code examples here: https://cognitiveseo.com/blog/13431/recover-facebook-shares-https/

Hope this helps you out!



来源:https://stackoverflow.com/questions/27261781/switching-from-http-to-https-lost-all-facebook-likes-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!