首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >就像Button,vBulletin和Mod重写

就像Button,vBulletin和Mod重写
EN

Stack Overflow用户
提问于 2012-09-19 23:21:16
回答 1查看 730关注 0票数 0

我在vBulletin上遇到了一个非常,非常,非常奇怪的问题,使用Facebook就像按钮一样。在我的线程模板中,我使用以下代码,它位于body标记中:

代码语言:javascript
复制
<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:raw sharingurl}就会被线程的规范URL替换,如下所示:

代码语言:javascript
复制
http://MYDOMAIN/threads/THREADID-THREADTITLE

例如:

代码语言:javascript
复制
http://www.mydomain.com/threads/1-Hello-Community

查看线程页的HTML源代码,一切似乎都如愿以偿:

代码语言:javascript
复制
<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>

但是如果我点击类似的按钮来分享线程页面..。这出戏来了:

线程页的原始URL被混乱地转换成如下所示:

代码语言:javascript
复制
http://MYDOMAIN/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/THREADID-THREADTITLE

有人知道我为什么会有这个奇怪的问题吗?我唯一想要自己解决的问题是我的htaccess文件,其中包含了一些重写规则。这几乎是vBulletin默认的..。但是,不管怎么说,它们在这里:

代码语言:javascript
复制
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调试器和.

刮擦信息

代码语言:javascript
复制
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

必须修正的关键错误

代码语言:javascript
复制
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.

必须修正的错误

代码语言:javascript
复制
Too Many Redirects: URL redirected too many times. Please reduce the number of redirects.

就像应该修复的按钮警告一样

代码语言:javascript
复制
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.

应该修复的开放图警告

代码语言:javascript
复制
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.

对象属性

代码语言:javascript
复制
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

重定向路径

代码语言:javascript
复制
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 )。

求你了求你了帮帮我!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-22 01:53:03

您可能需要添加meta标记。

代码语言:javascript
复制
 <meta type="og:url" content="<?php get_current_url(); ?>" >

试试看

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12504206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档