duanhuayong6687 2018-06-15 21:11
浏览 63

SSL打破Facebook Likes按钮

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
  • 写回答

3条回答 默认 最新

  • douzhenchun6782 2018-06-21 07:38
    关注

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真