在我的 vBulletin 板上使用 Facebook 的 Like 按钮时,我遇到了一个非常非常非常奇怪的问题。在我的线程模板中,我使用了以下代码,它位于 body 标记内:
<td class="vbs_forumdata alt1">
<div id="fb-root"></div>
<script type="text/javascript">(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id))return;js=d.createElement(s);js.id=id;js.src="//connect.facebook.net/en_US/all.js#xfbml=1";fjs.parentNode.insertBefore(js,fjs)})(document,"script","facebook-jssdk");</script>
<div id="thread_sharing_content_facebook">
<div class="fb-like" data-href="{vb:raw sharingurl}" data-layout="button_count" data-send="false" data-show-faces="false" data-width="90"></div>
</div>
</div>
</td>
一旦模板被 vBulletin 引擎处理,变量 {vb:rawsharingurl} 就会被线程的规范 URL 替换,如下所示:
http://MYDOMAIN/threads/THREADID-THREADTITLE
例如:
http://www.mydomain.com/threads/1-Hello-Community
查看线程页面的 HTML 源代码,一切似乎都按预期工作:
<td class="vbs_forumdata alt1">
<div id="fb-root"></div>
<script type="text/javascript">(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id))return;js=d.createElement(s);js.id=id;js.src="//connect.facebook.net/en_US/all.js#xfbml=1";fjs.parentNode.insertBefore(js,fjs)})(document,"script","facebook-jssdk");</script>
<div id="thread_sharing_content_facebook">
<div class="fb-like" data-href="http://www.mydomain.com/threads/1-Hello-Community" data-layout="button_count" data-send="false" data-show-faces="false" data-width="90"></div>
</div>
</div>
</td>
但是,如果我点击“Like”按钮来分享线程页面……戏剧性的来了:
线程页面的原始 URL 被搞砸了,变成了这样的东西:
http://MYDOMAIN/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/THREADID-THREADTITLE
任何人都知道为什么我会遇到这个奇怪的问题?我唯一想自己弄清楚的是我的 htaccess 文件,其中包含一些重写规则。这几乎是 vBulletin 的默认设置……但是,无论如何,它们是:
RewriteEngine On
RewriteBase /
// Block Bad Bots
RewriteCond %{HTTP_USER_AGENT} [...]
RewriteRule ^.*$ - [F,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^threads/.* showthread.php [QSA]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ - [NC,L]
RewriteRule ^(.*)$ - [R=404,L]
编辑:我尝试使用 Facebook URL 调试器和...
报废信息
Response Code: 200
Fetched URL: http://www.mydomain.com/threads/1-Hello-Community
Canonical URL: http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
必须修复的严重错误
Could Not Follow Redirect Path: Using data from http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community because there was an error following the redirect path.
必须修复的错误
Too Many Redirects: URL redirected too many times. Please reduce the number of redirects.
应该修复的按钮警告
Admins And App ID Missing: fb:admins and fb:app_id tags are missing. These tags are necessary for Facebook to render a News Feed story that generates a high click-through rate.
Like Button Tag Missing: og:title is missing. The og:title meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
Like Button Tag Missing: og:type is missing. The og:type meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
Like Button Tag Missing: og:image is missing. The og:image meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
应该修复的开放图警告
Inferred Property: The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property: The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property: The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property: The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.
对象属性
og:url: http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
og:type: website
og:title: #Page Title#
og:image:
og:description: #Meta Description#
og:updated_time: 1348134967
重定向路径
originale: http://www.mydomain.com/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
最终 URL 以粗体显示(这是我们尝试从中提取元数据的 URL)。
请,请,请...帮帮我!