Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL breaks Facebook Likes button

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
like image 744
Trenton Avatar asked Jun 15 '18 21:06

Trenton


2 Answers

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.

like image 57
Mukesh Panchal Avatar answered Sep 19 '22 23:09

Mukesh Panchal


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
like image 31
Charis Avatar answered Sep 21 '22 23:09

Charis