重定向到外部链接之前的中间页面

时间:2012-11-05 10:38:57

标签: php redirect hyperlink external

我是php的新手,已经在论坛上搜索了这个并找到了类似的东西,虽然我不明白它

我有2个外部链接http://www.hello.comhttp://www.bye.com

点击每个链接,我想用

加载一个中间页面(例如:redirect.php)5秒

消息:“你要离开misite.com。再见。”

然后,正确使用适用于每种情况的正确外部链接。

我需要:

1.- redirect.php的内容

  <a href="<?php $hello.com = $_GET['link']; ?>">Continue to external link</a>
  <a href="<?php $link = $_GET['link']; ?>">Continue to external link</a>

我确定这是错的。 另外,我不知道怎么放5秒旋转器(gif)然后再进行重定向(step3)

2.-链接用户点击它。好吗? 我有:

  <a href="http://redirect.php?link=hello.com" title="hello">hello</a>

不确定它是否正确 用户点击的链接,尝试调用重定向页面中的链接,但我无法

嗯,我不知道如何使它工作,我真的是一个例子 感谢

1 个答案:

答案 0 :(得分:-1)

您应该建立到redirect.php的链接,并添加&#34;最终目的地&#34;作为URL参数,就像您已经完成的那样。在redirect.php上,使用重定向的head部分中的元标记(有关示例,请参阅here)。

编辑:请求代码......

在你的主要php页面中,有你已经写过的链接:

<a href="http://redirect.php?link=hello.com">Hello</a>
<a href="http://redirect.php?link=goodbye.com">Goodbye</a>

在redirect.php中,您需要在HTML的<head>...</head>部分添加元标记:

<html>
    <head>
        ...
        <meta http-equiv="refresh" content="5;url=<?php echo $_GET['link'];?>" />
        ...
    </head>
    <body>
        <h1>You are leaving my site!</h1>
        <img src="/images/spinner.gif" alt="spinner" />
    </body>
</html>

就是这样。元标记&#34;内容&#34; attribute包含重定向前的秒数和重定向到的地址。

希望这会有所帮助。

相关问题