Chống Spam link cho Xenforo - Hướng dẫn tạo link nofollow cho Xenforo

nttruong

MasterCorporal
Tham gia
25/02/2015
Bài viết
368
Được Like
614
vnxf.vn - Để nhằm chống bớt bạn spam link cho website của bạn. Đây là cách tạo cho các link liên kết thành nofollow.

Tìm và mở /library/XenForo/Helper/String.php:

Mã:
public static function getLinkClassTarget($url)
{
$target = '_blank';
$class = 'externalLink';
$type = 'external';
$urlInfo = @parse_url($url);
if ($urlInfo)
{
$host = $urlInfo['host'] . (!empty($urlInfo['port']) ? ":$urlInfo[port]" : '');
if ($host == XenForo_Application::$host)
{
$target = '';
$class = 'internalLink';
$type = 'internal';
}
}
return array($class, $target, $type);
}

Thay thế bằng đoạn code sau:

Mã:
public static function getLinkClassTarget($url)
{
$target = '_blank';
$class = 'externalLink" rel="nofollow';
$type = 'external';
$urlInfo = @parse_url($url);
if ($urlInfo)
{
$host = $urlInfo['host'] . (!empty($urlInfo['port']) ? ":$urlInfo[port]" : '');
if ($host == XenForo_Application::$host)
{
$target = '';
$class = 'internalLink';
$type = 'internal';
}
}
return array($class, $target, $type);
}

Done! Chúc các bạn thành công!
 
Sửa lần cuối bởi điều hành viên:

Gia Khang

Gefreiter
Tham gia
02/03/2015
Bài viết
69
Được Like
110
Nếu ngại đụng chạm đến PHP thì các bạn có thể chèn code sau vào template PAGE_CONTAINER
Mã:
<script type="text/javascript">
jQuery(document).ready(function () {

jQuery('a[href*="http://"]:not([href*="http://domain.com"])').attr('rel', 'nofollow');

jQuery('a[href*="https://"]:not([href*="https://domain.com"])').attr("target", "_blank");

    });
</script>
ngay bên trên </header>

Thay domain.com bằng site của các bạn
Done!
 

Jindo_Katori

FirstSergeant
Tham gia
01/03/2015
Bài viết
1,462
Được Like
1,205
Nếu ngại đụng chạm đến PHP thì các bạn có thể chèn code sau vào template PAGE_CONTAINER
Mã:
<script type="text/javascript">
jQuery(document).ready(function () {

jQuery('a[href*="http://"]:not([href*="http://domain.com"])').attr('rel', 'nofollow');

jQuery('a[href*="https://"]:not([href*="https://domain.com"])').attr("target", "_blank");

    });
</script>
ngay bên trên </header>

Thay domain.com bằng site của các bạn
Done!

Cái này có phải là bất cứ nội dung bài viết nào có chứa link đều đưa về địa chỉ mình chỉ định không xếp?
Trường hợp link đó là của mình để hướng dẫn thành viên. Ví dụ: Link chỉ định là (Topic nội quy). Khi thành viên hỏi 1 vấn đề đã có trong 4r rồi và mình gửi link topic đó thì sao?
 

Gia Khang

Gefreiter
Tham gia
02/03/2015
Bài viết
69
Được Like
110
Cái này có phải là bất cứ nội dung bài viết nào có chứa link đều đưa về địa chỉ mình chỉ định không xếp?
Trường hợp link đó là của mình để hướng dẫn thành viên. Ví dụ: Link chỉ định là (Topic nội quy). Khi thành viên hỏi 1 vấn đề đã có trong 4r rồi và mình gửi link topic đó thì sao?
Cái này chỉ tác dụng với link ngoài thôi, với link thuộc site của mình thì vẫn bình thường nhé
 

Jindo_Katori

FirstSergeant
Tham gia
01/03/2015
Bài viết
1,462
Được Like
1,205
upload_2015-3-12_1-10-17.png


Hình chụp chèn code vào trên thẻ </header> trong template PAGE_CONTAINER nè xếp @Gia Khang
 
  • Like
Reactions: THB

Jindo_Katori

FirstSergeant
Tham gia
01/03/2015
Bài viết
1,462
Được Like
1,205
Em không có thẻ <body>
Chỉ có thẻ bắt đầu:
<body{xen:if {$bodyClasses}, ' class="{$bodyClasses}"'}>
<xen:hook name="body">
Và kết thúc:
</body>
Thì chèn thế này được không anh @nttruong
Full code PAGE_CONTAINER :
Mã:
<!DOCTYPE html><xen:set var="$isResponsive" value="{xen:if '@enableResponsive AND !{$noResponsive}', 1, 0}" />
<html id="XenForo" lang="{$visitorLanguage.language_code}" dir="{$visitorLanguage.text_direction}" class="Public NoJs {xen:if {$visitor.user_id}, 'LoggedIn', 'LoggedOut'} {xen:if {$sidebar}, 'Sidebar', 'NoSidebar'} {xen:if $hasAutoDeferred, RunDeferred} {xen:if $isResponsive, Responsive, NoResponsive}" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<xen:hook name="page_container_head">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <xen:if is="{$isResponsive}">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
    </xen:if>
    <xen:if is="{$requestPaths.fullBasePath}">
        <base href="{$requestPaths.fullBasePath}" />
        <script><xen:comment>/* Chrome bug and for Google cache */</xen:comment>
            var _b = document.getElementsByTagName('base')[0], _bH = "{xen:jsescape $requestPaths.fullBasePath}";
            if (_b && _b.href != _bH) _b.href = _bH;
        </script>
    </xen:if>

    <title><xen:if is="{$title}">{xen:raw $title} | {$xenOptions.boardTitle}<xen:else />{$xenOptions.boardTitle}</xen:if></title>
   
    <noscript><style>.JsOnly, .jsOnly { display: none !important; }</style></noscript>
    <link rel="stylesheet" href="css.php?css=xenforo,form,public&amp;style={xen:urlencode $_styleId}&amp;dir={$visitorLanguage.text_direction}&amp;d={$visitorStyle.last_modified_date}" />
    <!--XenForo_Require:CSS-->   
    {xen:helper ignoredCss, {$visitor.ignoredUsers}}

    <xen:include template="google_analytics" />
    <xen:include template="page_container_js_head" />
   
    <link rel="apple-touch-icon" href="{xen:helper fullurl, @ogLogoPath, 1}" />
    <link rel="alternate" type="application/rss+xml" title="{xen:phrase rss_feed_for_x, 'title={$xenOptions.boardTitle}'}" href="{xen:link forums/-/index.rss}" />
    <xen:if is="{$pageDescription.content} AND !{$pageDescription.skipmeta} AND !{$head.description}"><meta name="description" content="{xen:string wordTrim, {xen:helper stripHtml, {xen:raw $pageDescription.content}}, 200}" /></xen:if>
    <xen:if is="{$head}"><xen:foreach loop="$head" value="$headElement">{xen:raw $headElement}</xen:foreach></xen:if>
   
   
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta http-equiv="content-language" content="vi" />
<title>
Tuyhoaplus.com - Diễn Đàn Tuy Hòa Phú Yên, Mua Bán,Giá Rẻ,  Việc Làm, Tuyển Dụng, Du Lịch
</title>
<meta name="description" content="Tuyhoaplus.com - Diễn Đàn Tuy Hòa Phú Yên, Mua Bán, Giá Rẻ, Việc Làm, Tuyển Dụng, Du Lịch" />
<meta name="keywords" content="Tuyhoaplus.com - Diễn Đàn Tuy Hòa Phú Yên, Mua Bán,Giá Rẻ,  Việc Làm, Tuyển Dụng, Du Lịch" />
<meta name="robots" content="noodp,index,follow" />
<meta name='revisit-after' content='1 days' />
   
   
</xen:hook>
</head>


[COLOR=#ff0000]<script type="text/javascript"> 
jQuery(document).ready(function () { 
jQuery('a[href*="http://"]:not([href*="http://tuyhoaplus.com"])').attr('rel', 'nofollow'); 
jQuery('a[href*="https://"]:not([href*="http://tuyhoaplus.com"])').attr("target", "_blank"); }); </script>[/COLOR]


<body{xen:if {$bodyClasses}, ' class="{$bodyClasses}"'}>
<xen:hook name="body">


<xen:if is="{$visitor.is_moderator} || {$visitor.is_admin}">
    <xen:include template="moderator_bar" />
<xen:elseif is="!{$visitor.user_id} && !{$hideLoginBar}" />
    <xen:include template="login_bar" />
</xen:if>

<div id="headerMover">
    <div id="headerProxy"></div>

<div id="content" class="{$contentTemplate}">
    <div class="pageWidth">
        <div class="pageContent">
            <!-- main content area -->
           
            <xen:hook name="page_container_content_top" />
           
            <xen:if is="{$sidebar}">
                <div class="mainContainer">
                    <div class="mainContent"></xen:if>
                       
                        <xen:include template="ad_above_top_breadcrumb" />
                       
                        <xen:hook name="page_container_breadcrumb_top">
                        <div class="breadBoxTop {xen:if $topctrl, withTopCtrl}">
                            <xen:if is="{$topctrl}"><div class="topCtrl">{xen:raw $topctrl}</div></xen:if>
                            <xen:include template="breadcrumb"><xen:set var="$microdata">1</xen:set></xen:include>
                        </div>
                        </xen:hook>
                       
                        <xen:include template="ad_below_top_breadcrumb" />
                   
                        <!--[if lt IE 8]>
                            <p class="importantMessage">{xen:phrase you_are_using_out_of_date_browser_upgrade}</p>
                        <![endif]-->

                        <xen:hook name="page_container_notices">
                        <xen:include template="notices" />                       
                        </xen:hook>
                       
                        <xen:hook name="page_container_content_title_bar">
                        <xen:if is="!{$noH1}">                       
                            <!-- h1 title, description -->
                            <div class="titleBar">
                                {xen:raw $beforeH1}
                                <h1><xen:if
                                    is="{$h1}">{xen:raw $h1}<xen:elseif
                                    is="{$title}" />{xen:raw $title}<xen:else
                                    />{$xenOptions.boardTitle}</xen:if></h1>
                               
                                <xen:if is="{$pageDescription.content}"><p id="pageDescription" class="muted {$pageDescription.class}">{xen:raw $pageDescription.content}</p></xen:if>
                            </div>
                        </xen:if>
                        </xen:hook>
                       
                        <xen:include template="ad_above_content" />
                       
                        <!-- main template -->
                        {xen:raw $contents}
                       
                        <xen:include template="ad_below_content" />
                       
                        <xen:if is="!{$visitor.user_id} && !{$hideLoginBar}">
                            <!-- login form, to be moved to the upper drop-down -->
                            <xen:include template="login_bar_form" />
                        </xen:if>
                       
                    <xen:if is="{$sidebar}"></div>
                </div>
               
                <!-- sidebar -->
                <aside>
                    <div class="sidebar">
                        <xen:hook name="page_container_sidebar">
                        <xen:include template="ad_sidebar_top" />
                        <xen:if is="!{$noVisitorPanel}"><xen:include template="sidebar_visitor_panel" /></xen:if>
                        {xen:raw $sidebar}
                        <xen:include template="ad_sidebar_bottom" />
                        </xen:hook>
                    </div>
                </aside>
            </xen:if>
           
            <xen:hook name="page_container_breadcrumb_bottom">           
            <div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
            </xen:hook>
                       
            <xen:include template="ad_below_bottom_breadcrumb" />
                       
        </div>
    </div>
</div>

<header>
    <xen:include template="header" />
    <xen:edithint template="navigation" />
    <xen:edithint template="search_bar" />


<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('a[href*="http://"]:not([href*="http://tuyhoaplus.com"])').attr('rel', 'nofollow');
jQuery('a[href*="https://"]:not([href*="http://tuyhoaplus.com"])').attr("target", "_blank"); }); </script>


</header>

</div>

<footer>
    <xen:include template="footer" />
</footer>

<xen:include template="page_container_js_body" />

<xen:if is="{$isIndexPage} AND {$canSearch}">
<script type="application/ld+json">
{
    "@context": "http://schema.org",
    "@type": "WebSite",
    "url": "{xen:jsescape {xen:link canonical:index}}",
    "potentialAction": {
        "@type": "SearchAction",
        "target": "{xen:jsescape {xen:link canonical:search/search}}{xen:if $xenOptions.useFriendlyUrls, '?', '&'}keywords={search_keywords}",
        "query-input": "required name=search_keywords"
    }
}
</script>
</xen:if>

</xen:hook>


<div class="slide_likebox">
<div style="color: rgb(255, 255, 255); padding: 8px 5px 0pt 50px;">
<div class="FB_Loader"></div>
<span><iframe src="http://www.facebook.com/plugins/likebox.php?href=https://www.facebook.com/pages/Tuy-H%C3%B2a-Plus/768077466598626
&amp;
width=198&amp;
colorscheme=light&amp;
show_faces=true&amp;
stream=false&amp;
header=false&amp;
height=368" scrolling="no" frameborder="0" style="border:none;
overflow:hidden;
width:198px;
height:368px;" allowTransparency="true">
</iframe></span></div></div>


</body>
</html>
 

Blue

Founder
Thành viên BQT
Tham gia
25/02/2015
Bài viết
909
Được Like
1,528
Làm kiểu anh Trường post đi, chơi jquery không tốt trên google search đâu, jquery làm đẹp là chính :))
 

Jindo_Katori

FirstSergeant
Tham gia
01/03/2015
Bài viết
1,462
Được Like
1,205
Làm kiểu anh Trường post đi, chơi jquery không tốt trên google search đâu, jquery làm đẹp là chính :))
Vừa thay vào thử
upload_2015-3-14_23-11-32.png


Tiêu em rồi
upload_2015-3-14_23-10-38.png



Thay về lại như cũ cũng không được (không biết file string có giống nhau không)
Bác nào teamview giúp em với.
Hậu quả nghiêm trọng rồi
 
Sửa lần cuối:
  • Like
Reactions: THB
Người đăng Chủ đề tương tự Diễn đàn Trả lời Ngày đăng
THB Tutorial For SEOer 7
THB Tutorial For SEOer 0

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mr. Tuấn

Mobile/Zalo: 0988 488 096

Telegram: bluekpro

Email: [email protected]

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Top Bottom