SSL打破Facebook Likes按钮

Tre*_*ton 6 php wordpress ssl facebook-like facebook-graph-api

我的博客https://sonicscoop.com的历史可以追溯到2012年,有数百个Facebook"喜欢",例如这个https://sonicscoop.com/2012/08/29/the-big-list- of-free-pro-tools-plugins-2 /,但是当我们切换到https:这里时,他们都丢失了正确的计数,如下所示:

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

出于某种原因,Facebook的调试器检测规范,并og:urlhttps://即使网页呈现的HTML显示他们作为http://.

如果我可以让Facebook拿起旧版帖子的http规范,我希望喜欢的人会回到正确的数量.这是我的.htaccess档案:

# --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
Run Code Online (Sandbox Code Playgroud)

小智 1

当 Facebook 抓取您的页面时,它会被重定向到您页面的 https 版本。即使你的 og:url 使用 http 版本,我认为 facebook 仍然会使用你页面的规范或最终 url。

尝试将 .htaccess 上的重写条件更改为:

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
Run Code Online (Sandbox Code Playgroud)