內容簡介
當你將博客從HTTP轉換為HTTPS時,所有的帖子/頁面都會失去Facebook的讚和分享數。唯一重新獲得這些讚和分享數的方法是添加一個‘OG URL’標籤,並將其指向舊的‘HTTP’ URL,如Facebook所述,詳見此處。
這個WordPress外掛可以幫助你實現這一點。
例如,如果你使用像Yoast這樣的SEO插件,OG URL標籤會自動反映HTTPS版本的URL。這個外掛會添加一個過濾器到‘OG URL’的輸出中,並將所有現有的帖子/頁面都更改回‘HTTP’版本。啟用此外掛後添加的新帖子/頁面不會受到影響。
同樣地,正版URL標籤保持不變,為‘HTTPS’。這個標籤由搜索引擎如Google使用,因此當涉及到SEO時你不需要擔心。
這個外掛會更改以下流行插件的OG URL輸出:
Yoast SEO插件
ALL In One SEO Pack
WP Facebook開放圖形協議by Chuck Reynolds
Facebook開放圖形、Google+和Twitter卡片標籤插件by Webdados
注意
此外掛僅會更改在安裝時已經存在的帖子/頁面中的‘OG URL’標籤。這樣所有新發布的帖子都會有正常的OG URL標籤,並且都為‘HTTPS’。
實現外掛的步驟
你需要按照以下步驟來實現此外掛:
步驟1:下載並安裝此外掛。
步驟2:如果你使用了緩存插件(例如:WP Super Cache),請刪除緩存。
步驟3:在你的.HTaccess文件中排除Facebook機器人免受HTTP到HTTPS重定向的影響。以下是一個示例:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule ^(.*)$ https://sitename.com/$1 [R=301,L]
上述重寫規則排除了Facebook機器人的重定向。
步驟4:等待30天,直到Facebook重新抓取您的網頁。當Facebook重新抓取您的頁面時,您的分享計數將返回。
檢測外掛是否有效
你可以立即檢查你是否已經正確實現此外掛,強制Facebook重新抓取一個或多個頁面。具體操作如下:
登錄Facebook帳戶,進入Facebook調試工具
輸入一個你的頁面/帖子的‘HTTPS’ URL,然后點擊‘Debug’按鈕。
如果你收到了“此URL尚未在Facebook上分享。”的消息,請點擊‘Fetch New Information’按鈕。
現在點擊‘Scrap Again’。你現在應該能夠看到所有你頁面的‘讚’,你也可以在‘Redirect path’標題下看到兩個URL,反映了您的og:url元標籤和原始的HTTPS URL。
即使您沒有手動重抓您的URL,Facebook 也會在30天內自動重新抓取你的URL。所以你的所有‘分享計數’都會在30天內恢復。
想添加新功能?
如果你想添加新功能到這個外掛中,只需發送一封電子郵件給我。 點此找到我的郵件地址。
外掛標籤
開發者團隊
原文外掛簡介
When you shift your blog from HTTP to HTTPS, all your posts/pages lose facebook likes/share count. The only way to regain these likes/share counts is to add a ‘OG URL’ tag that points back to the older ‘HTTP’ urls as described here by Facebook.
This plugin helps you do just that.
For example, if you use a SEO plugin like Yoast, the OG URL tag automatically reflects the HTTPS version for HTTPS URLs. This plugin adds a filter to the ‘OG URL’ output and changes it back to ‘HTTP’ for all existing posts/pages. New posts that you add after this plugin is activated will not be affected.
Similary, the canonical URL tag remains unchanged as ‘HTTPS’. Canonical tag is used by search engines like Google. So you are good when it comes to SEO.
This plugin changes the OG URL output for the following popular plugins:
Yoast SEO Plugin
ALL In One SEO Pack
WP facebook open graph protocol by Chuck Reynolds
Facebook Open Graph, Google+ and Twitter Card Tags plugin by Webdados
Note
This plugin only changes the ‘OG URL’ tags for posts that existed when this plugin is first installed. This way all new posts will have the regular OG URL tags with ‘HTTPS’.
Steps to make this work
You need to follow these steps in order for the plugin to work:
Step 1: Install and activate the plugin.
Step 2: If you are using a Cache plugin (eg: WP Super Cache), delete the cache.
Step 3: Exclude facebook bot from the HTTP to HTTPS redirection in your HTaccess file. Here’s an example:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule ^(.*)$ https://sitename.com/$1 [R=301,L]
The above rewrite rule excludes facebook bots from the redirect.
Step 4: Wait for 30 days for facebook to rescrape your pages. Your ‘share count’ will return when facebook rescrapes your page.
Test to see if this works
You can instantly check to see if you did everything right by forcing facebook to rescrape one or many of your pages. Here’s how you can do that:
Login to your facebook account and go to Facebook debugger tool
Enter the ‘HTTPS’ url of one of your pages/posts and click the ‘Debug’ button.
If you get the “This URL hasn’t been shared on Facebook before.” message,click on the ‘Fetch New Information’ button.
Now click ‘Scrap Again’. You should now be able to see all your ‘likes’ to the page. You would also see two URLs under the ‘Redirect path’
heading which reflects your og:url meta tag and your original HTTPS URL.
Even if you do not manually rescrape your URLs, facebook will automatically rescape your URLs within 30 days. So all your ‘share counts’ will return within 30 days.
For detailed information on these steps, check out this article
Want any new features?
Want any new features added to this plugin? Just send me an email. You can find my email here.
