PHP-重定向网站信息


PHP - Redirect website with information

我想将用户重定向到网站,并在网站中显示信息"重定向…请稍候"。禁食的方法是什么?我可以使用HTML和PHP。

尝试一下:

<!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>

如果要使用php执行此操作,可以使用header()函数发送新的HTTP标头,但必须在任何HTML或文本之前(甚至在声明之前)将其发送到浏览器。

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

或者你尝试类似的重定向状态代码-301302等

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);

否则,使用html 很容易实现

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

这里content是您想要延迟的秒数