【问题标题】:Redirect all link in site to redirect page [duplicate]将站点中的所有链接重定向到重定向页面[重复]
【发布时间】:2015-03-17 05:23:19
【问题描述】:

我不知道这个问题的正确标题。 昨天我发现了这个网站http://www.hyper-hippo.net/ 每次我点击帖子页面中的链接,链接转到重定向页面。它是如何工作的? 该网站在博客中创建它。 也许脚本和 adf.ly 一样,但是怎么做呢?

以及如何制作重定向页面,当在地址栏中输入?url=www.google.com 将转到重定向页面,链接将转到google.com。

【问题讨论】:

  • 我不太擅长网络技术。 AFAIK,重定向将从服务器端发生。例如,您正在联系 adf.ly/qNMFHF45 ,服务器将向您发送带有新 URL (you-blog-link.com) 的 HTTP 重定向代码 302,浏览器捕获 302 信号并立即联系新位置。这样你的博客就被加载了。

标签: php .htaccess


【解决方案1】:

您可以在 html 的 head 部分中使用 meta 标签,如下所示

<meta http-equiv="refresh" content="0; url=http://example.com/" />

【讨论】:

    【解决方案2】:

    也许我可以帮忙。 在 ASP.NET 中,我们使用 AdRotator 来重定向页面。 这意味着您可以使用 adRotator 构建一个类似于“hyper-hippo.net”的页面。

    这是一个示例:在 ASP.NET 中

    $sql = mysql_query("SELECT * FROM sites WHERE sites ='" . $_POST["sitess"] . "'");
    $id = mysql_fetch_array($sql);
    
    <p><a href="ad1.xml" target="_blank">View XML file</a></p>
    

    这是 PHP 中的另一个例子:

    $ads = array("ad code goes here", "more ad code", "more ad code");
    shuffle($ads);
    print $ads;
    

    这是 HTML 中的另一个

    <div id="rotator">
        <img class="ad" src="#" />
        <img class="ad" src="#" />
        <img class="ad" src="#" />
        <img class="ad" src="#" />
    </div>
    

    这是另一种 JS + HTML

    <div id="rotator">
        <img class="ad" src="ad_banner1.png" />
        <img class="ad" src="ad_banner2.png" />
        <img class="ad" src="ad_bannerN.png" />
    </div>
    
    <script type="text/javascript">// Fisher-Yates Algorithm written by Gio Borje <http://www.giocc.com>
    (function() {
        // Get the list of ads on your site
        var ads = document.getElementsByClassName("ad");
    
        // Used for swapping in the algorithm
        var tmp;
    
        // Random index to swap with
        var randomIdx;
    
        // Random sorting algorithm
        for (var i = 0; i < ads.length - 1; i++) {
            randomIdx = i + 1 + Math.floor(Math.random() * (ads.length - i));
            tmp = ads[randomIdx].src;
            ads[randomIdx].src = ads[i].src;
            ads[i].src = tmp;
        }
    }​)();</script>
    

    希望能帮到你!!!

    【讨论】:

      【解决方案3】:

      您可以像这样使用header() 函数:

      if (isset($_GET['url'])){ //check if URL is set in adress
          $url = htmlspecialchars(filter_input(INPUT_GET, 'url'), ENT_COMPAT, 'UTF-8'); // XSS attack prevention 
          if(strpos($url,'http://')>0 ||strpos($url,'https://')>0){ // check if the address is http://example.com or example.com
              header('Location: '.$url.'/'); // redirection code of php
          } else {
              header('Location: http://'.$url.'/');
          }
      }
      

      【讨论】:

        【解决方案4】:

        要做到这一点,请按以下步骤操作:

        1。链接是使用目标空白。

        例子:

        在新窗口或标签中打开链接:

        <a href="alvinshortener.com/index.php?url=www.google.com" target="_blank">Visit </a>
        

        在 index.php 里面写:

        <?php
        if(isset($_GET['url'])){
        header("Location: $_GET['url']");
        }
        ?>
        

        【讨论】:

          猜你喜欢
          • 2013-10-25
          • 2019-03-31
          • 1970-01-01
          • 2014-10-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-06-18
          相关资源
          最近更新 更多