SSL breaks Facebook Likes button
Asked Answered
V

3

6

My blog https://sonicscoop.com has older posts dating all the way back to 2012 with hundreds of Facebook "likes" such as this one https://sonicscoop.com/2012/08/29/the-big-list-of-free-pro-tools-plugins-2/, but they all lost their correct count when we switched to https: as you can see here:

https://developers.facebook.com/tools/debug/sharing/?q=https%3A%2F%2Fsonicscoop.com%2F2012%2F08%2F29%2Fthe-big-list-of-free-pro-tools-plugins-2%2F

For some reason Facebook's debugger is detecting the canonical and og:url as https:// even though the page's rendered HTML shows them as http://.

If I can get Facebook to pick up the http canonical for older posts I'm hoping the likes will return to the correct count. Here is my .htaccess file:

# --enable htaccess rewrites
RewriteEngine on
# --force https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# --remove www for site
RewriteCond %{HTTP_HOST} ^www\.sonicscoop\.com [NC]
RewriteRule ^(.*)$ https://sonicscoop.com/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
AddHandler application/x-httpd-php54s .php
Valdivia answered 15/6, 2018 at 21:11 Comment(4)
Do you have a htaccess or other redirect to enforce HTTPS?Skyla
@JustinR. I updated the question to include my htaccessValdivia
I'm pretty sure it's because the button code is specifying your URL as https... <iframe src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fsonicscoop.com Note the https in the href query string parameter.Situate
You need to implement an exemption in your HTTP to HTTPS redirect for the Facebook scraper – otherwise, when it requests the old HTTP URL as instructed, you are telling it “no, this has moved to https://…” right afterwards, thereby nullifying that you pointed it to the HTTP version in the first place. developers.facebook.com/docs/plugins/faqs#faq_1149655968420144Rms
A
2

Try below solution

1) WordPress Dashboard

2) After moving your site files (if necessary), log into your your WordPress Dashboard as an administrator. Next, click on Settings from the menu, and then General.

3) Click on General to get started.

4) The two fields we'll change are WordPress Address (URL) and Site Address (URL) set https for both url

5) Scroll down the page and click on the Save Changes button.

6) After that Settings > Permalinks

7) Scroll down if needed and click "Save Changes".

after above all steps check og:url then check if FB like is working for you.

Aglaia answered 21/6, 2018 at 8:26 Comment(0)
C
1

When facebook crawl your page it got redirected to https version of your page. Even if your og:url use http version, I think facebook will still use the canonical or final url of your page.

Try to change your rewrite condition on .htaccess into something like:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# --remove www for site
RewriteCond %{HTTP_HOST} ^www\.sonicscoop\.com [NC]
RewriteRule ^(.*)$ https://sonicscoop.com/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
AddHandler application/x-httpd-php54s .php
Cowbell answered 21/6, 2018 at 7:38 Comment(0)
B
0

You can use Really simple SSL plugin if it is wordpress site.

  1. Install plugin and activate.
  2. Go to settings you can see SSL. CLICK on it.
  3. enable ssl.

    This plugin will take all ssl issues.

Burl answered 27/6, 2018 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.