Navigation

    NodeBB-CN
    • Register
    • Login
    • Search
    • Categories
    • Unread
    • Recent
    • Tags
    • Users
    • Groups
    • 文档
    • 统计

    防止权重丢失 - 做个URL跳转页

    技术分享
    4
    12
    6998
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • a632079
      a632079 PA Team last edited by a632079

      来自 https://i.a632079.me

      搜索引擎上是根据什么来确定网站的先后顺序的呢?排除掉关键字的因素,剩余的因素就是网站本身的权重了。

      那权重是什么?

      网站权重是指搜索引擎给网站(包括网页)赋予一定的权威值,对网站(含网页)权威的评估评价。一个网站权重越高,在搜索引擎所占的份量越大,在搜索引擎排名就越好。提高网站权重,不但利于网站(包括网页)在搜索引擎的排名更靠前,还能提高整站的流量,提高网站信任度。所以提高网站的权重具有相当重要的意义。 权重即网站在SEO中的重要性,权威性。英文:Page Strength。CuteSEO资讯列表1、权重不等于排名 2、权重对排名有着非常大的影响 3、整站权重的提高有利于内页的排名。

      该词条来自《百度百科》

      首先,权重是一个综合的因素。服务器环境,文章内容质量,域名这些因素都是既定的,我们现在也没办法改变这些,但我们可以通过制作一个URL跳转页来避免你的流量流失,影响权重。

      在开始之前

      很多站点都有类似评论的功能,在评论框中留言者可以任意填写网址。但是很多时候我们不希望自己的网站存在过多杂乱的外部链接。当然,我们可以为链接加上nofollow属性。即本来链接代码是:

      <a href="https://i.a632079.me">藤球的窝</a>
      

      当我们给这个链接加上rel="nofollow"属性时,即告诉搜索引擎此链接地址不要传权重过去。形如:

      <a href="https://i.a632079.me" rel="nofollow">藤球的窝</a>
      

      配置页面

      但是,我们今天讲得并不是这种方法。我们的目标是将baidu.com重定向到yourdomain.com/?jump=http://baidu.com。
      本身我是想集成腾讯的网址安全检查的,但是高中太忙了,根本没时间做完啊:(
      亲们只需要把下面的代码保存为url.html放到自己站点的根目录。(什么,丑?不满意自己写啊,Doge呵斥)

      <!doctype html>
      <html class="no-js">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="description" content="">
        <meta name="keywords" content="">
          <meta name="theme-color" content="#0e90d2">
        <meta name="viewport"
              content="width=device-width, initial-scale=1">
        <title>外链安全跳转</title>
      
        <!-- Set render engine for 360 browser -->
        <meta name="renderer" content="webkit">
      
        <!-- No Baidu Siteapp-->
        <meta http-equiv="Cache-Control" content="no-siteapp"/>
      
        <link rel="icon" type="image/png" href="https://f.mypcqq.cc/favicon.ico">
        <link rel="stylesheet" href="https://cdn.staticfile.org/amazeui/2.7.2/css/amazeui.min.css">
         <style>
              .footer{
                  position: fixed !important;
                  bottom: 0 !important;
                  width: 100%;
      }
          </style>
      </head>
      <body>
        <header data-am-widget="header"
                class="am-header am-header-default">
      
            <h1 class="am-header-title" align="center" style="color:#fff;width:auto;">
                  <a href="https://www.mypcqq.cc/url-security.html" class="">
      
                      <i class="am-header-icon am-icon-shield"></i>
                </a>
                <a href="https://www.mypcqq.cc/url-securiry.html" class="">
                  外链跳转
                </a>
            </h1>
      </header>
       <br />
        <article data-am-widget="paragraph"
                 class="am-paragraph am-paragraph-default"
                 
                 data-am-paragraph="{ tableScrollable: true, pureview: true }">
        <div class="am-alert am-alert-warning"><i class="am-icon-warning"> </i> 网站风险未知,注意识别,谨防诈骗。 </div>
       <small>跳转网址:<a id="ulink"></a></small>
               <br />
              
                
                <img src="https://piccdn.freejishu.com/images/2017/01/02/CU50.jpg" style="margin-left:auto;margin-right:auto;max-width:900px;max-height:600px" />
       
               <br />
                <br />
                  
              
      </article>
          <div class="footer" style="padding:10px;max-width:980px;margin:auto;background-color:#fff">
              <small><p style="color:green;text-align:center;">安全检查结果为安全时,自动跳转。</p></small>
              <button type="button" class="am-btn am-btn-secondary am-btn-block" onclick = "javascript:jump()">我知道了,立即跳转</button>
           </div>
          
      
      
      <!--在这里编写你的代码-->
      
      
      <!--[if (gte IE 9)|!(IE)]><!-->
      <script src="https://cdn.staticfile.org/jquery/2.2.3/jquery.min.js"></script>
      <!--<![endif]-->
      <!--[if lte IE 8 ]>
      <script src="https://cdn.staticfile.org/jquery/1.11.3/jquery.min.js"></script>
      <script src="https://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
      <script src="https://cdn.staticfile.org/amazeui/2.7.2/js/amazeui.ie8polyfill.min.js"></script>
      <![endif]-->
      <script src="https://cdn.staticfile.org/amazeui/2.7.2/js/amazeui.min.js"></script>
      <script>
      function GetRequest() {
          var url = location.search; //获取url中"?"符后的字串
          var theRequest = new Object();
          if (url.indexOf("?") != -1) {
              var str = url.substr(1);
              strs = str.split("&");
              for(var i = 0; i < strs.length; i ++) {
                  theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
              }
          }
          return theRequest;
      }
      function jump(){
      window.location.href = url;
      }
      var Request = new Object();
      Request = GetRequest();
      var url;
      url = decodeURIComponent(Request['jump']);
      //alert(url);
      //$("#ulink").attr('href',url); 
      $("#ulink").text(url);
      </script>
      </body>
      </html>
      

      重定向

      在你完成上传之后,由于不知道你的网站是什么系统,你可以修改自己的网站模板(今天不讲这个),也可以通过JavaScript来重定向你的网站。
      在你页面的末尾加一个<script></script>标签,将下面的代码放到中间即可。
      以下代码必须引用JQuery才能正常执行

      //如果网站页面超过1000行,还是想办法改模板吧。。
      $("a").each(function(){
      if($(this).attr("href").search("//yourdomain.com") == -1){
      var jump = "//yourdomain.com/url.html?jump=" + $(this).attr("href");
      $(this).attr("href",jump);
      }
      });
      

      参考文章:《给网站外链进行重定向跳转 - 小祥子》
      《网站权重 - 百度百科》

      1 Reply Last reply Reply Quote 0
      • anubis
        anubis last edited by

        TEST…

        1 Reply Last reply Reply Quote 0
        • Corps
          Corps last edited by

          这么说么。。。
          我还是提供一个JavaScript的原生代码吧,第二段的恩;

          document.getElementsByTagName("a").forEach(function(a){
          	a.href = a.href.indexOf("//yourdomain")===-1?"/url.html?jump="+a.href:a.href;
          });
          
          a632079 jmglsi 3 Replies Last reply Reply Quote 0
          • a632079
            a632079 PA Team @Corps last edited by

            @corps Thanks a lot.

            1 Reply Last reply Reply Quote 0
            • Corps
              Corps last edited by

              不过如果对于友链也这么干的就有点耐人寻味了

              我记得遇到过一个人,把友链的链接全部nofollow

              然后还发了篇博文

              避免友链影响网站权重

              。真不知道说什么好

              a632079 1 Reply Last reply Reply Quote 0
              • a632079
                a632079 PA Team @Corps last edited by scvoet

                @corps 2333,只是提供个思路嘛…友链都这么干确实过分了

                1 Reply Last reply Reply Quote 0
                • a632079
                  a632079 PA Team @Corps last edited by

                  @corps 在 防止权重丢失 - 做个URL跳转页 中说:

                  document.getElementsByTagName(“a”).forEach

                  需要注意的是: 该操作不会生效.这的返回类型是 object 而不是 array

                  1 Reply Last reply Reply Quote 0
                  • jmglsi
                    jmglsi PA Team @Corps last edited by a632079

                    @corps 这的返回类型是 object 而不是 array

                    需要这样:

                    function Preview()
                    {
                          //do...
                    }
                    
                    var allhref = document.getElementsByTagName("a");
                    var a = Array.prototype.slice.call(allhref);
                    //Array.prototype.slice.call  解释:http://www.cnblogs.com/littledu/archive/2012/05/19/2508672.html
                    a.forEach(Preview);
                    
                    a632079 1 Reply Last reply Reply Quote 0
                    • a632079
                      a632079 PA Team @jmglsi last edited by

                      @jmglsi 在 防止权重丢失 - 做个URL跳转页 中说:

                      @corps 这的返回类型是 object 而不是 array

                      需要这样:
                      <code class=“language-JavaScript hljs”>
                      function Preview()
                      {
                      //do…
                      }

                      var allhref = document.getElementsByTagName(“a”);
                      var a = Array.prototype.slice.call(allhref);
                      //Array.prototype.slice.call 解释:http://www.cnblogs.com/littledu/archive/2012/05/19/2508672.html
                      a.forEach(Preview);
                      </code>

                      23333,并不能直接解析HTML…我帮你加上了

                      1 Reply Last reply Reply Quote 0
                      • Corps
                        Corps last edited by

                        做个指正…并不是Array,也不是Object(狭义).而是HTMLCollection

                        这样

                        [].forEach.call(document.getElementsByTagName("a"),function(a){
                        	a.href = a.href.indexOf("//yourdomain")===-1?"/url.html?jump="+a.href:a.href;
                        });
                        
                        jmglsi 1 Reply Last reply Reply Quote 1
                        • jmglsi
                          jmglsi PA Team @Corps last edited by jmglsi

                          @corps 0_gyahi.png 这样没毛病

                          Corps 1 Reply Last reply Reply Quote 0
                          • Corps
                            Corps @jmglsi last edited by

                            @jmglsi 说实话这样没意义来着.必须在后端操作,才能保证爬虫读取页面是处理后的页面.毕竟爬虫可没用PhantomJS

                            1 Reply Last reply Reply Quote 1
                            • 1 / 1
                            • First post
                              Last post

                            Powered by NodeBB • © 2017 - 2021 SoarTeam & PA Team All Rights Reserved • Accelerated by UpYun