从HTTP切换到HTTPS,失去了所有的Facebook "Likes"



切换到 https://后,我们所有的文章都失去了Facebook的"赞"计数。因此,我想仅为我们网站的内容区域禁用https,该区域位于/content.php(文章以内容形式.php?212-My-Article)

我目前的 .htaccess:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

我需要添加什么,以便将所有内容.php*流量重定向到http(不安全),即使它们键入" https"

谢谢!

您可以使用以下代码:

RewriteEngine on
# uri is not /content.php
RewriteCond %{REQUEST_URI} !^/content.php$ [NC]
# https is off
RewriteCond %{HTTPS} off
# redirec to https site
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

我找到了一种方法来解决这个问题,而不会使内容.php不安全。Facebook的"喜欢"HTML代码看起来像这样:

<fb:like href="https://www.mysite.com/{vb:raw relpath}" font="tahoma" layout="standard" show_faces="false" width="260" action="like" colorscheme="light"></fb:like>

我使用 vBulletin。我把它改成了http,现在一切都很好!

您需要

更改第一个规则以排除content.php 。您只需为content.php添加一个规则,该规则将与您的其他规则完全相反。如果您的规则执行了您希望它们执行的操作以将其转换为永久重定向,则可以添加 [R=301] 标志。永久重定向由浏览器缓存,将减少对服务器的请求量。您不需要为第一条规则使用捕获组,因此我只使用了与每个请求匹配的^语法。

RewriteEngine on
#Turn the entire site into https, except for content.php
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/content.php$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
#Use http instead for this url
RewriteCond %{HTTPS} on
RewriteCond ^content.php$ http://%{HTTP_HOST}%{REQUEST_URI}

有一个非常简单的解决方案:使用 og:url 元标记:

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

您可以在常见问题解答部分阅读更多相关信息:https://developers.facebook.com/docs/plugins/faqs

该部分称为:如何将页面移动到其他 URL?

最新更新