0

我想将用户重定向到网站,并在网站上显示“重定向...请稍候”信息。最快的方法是什么?我可以使用 HTML 和 PHP。

4

2 回答 2

5

试试这个:

<!DOCTYPE HTML>
<html>
<head>
    <title>Page Moved</title>
    <meta http-equiv="refresh" content="3;URL='http://www.example.com/'" />    
</head>
<body>
    <p>This page has moved to <a href="http://www.example.com/">www.example.com</a>.</p>
    <p>You will be redirected within 3 seconds.</p>
</body>
</html>
于 2013-07-30T10:39:01.313 回答
0

如果你想用 来做到这一点php,你可以使用 header() 函数发送一个新的 HTTP 头,但这必须在任何 HTML 或文本之前发送到浏览器(甚至在声明之前)。

header('Location: '.$newURL);
die();

或者您尝试类似的涉及重定向状态代码的操作 - 301,302 等

function Redirect($url, $permanent = false)
{
  if (headers_sent() === false)
    {
       header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
       die();
    }

 exit();
}

Redirect('http://www.example.com/', false);

else 用 html 很容易实现

<meta http-equiv="refresh" content="3;URL='http://www.example.com/' />

content是您要延迟的秒数。`

于 2013-07-30T10:40:50.713 回答