PHP-用信息重定向网站
我想将用户重定向到一个网站,并在网站中显示信息“重定向…请稍候”。最快的方法是什么?我可以使用HTML和PHP。尝试一下:PHP-用信息重定向网站,php,html,redirect,Php,Html,Redirect,我想将用户重定向到一个网站,并在网站中显示信息“重定向…请稍候”。最快的方法是什么?我可以使用HTML和PHP。尝试一下: <!DOCTYPE HTML> <html> <head> <title>Page Moved</title> <meta http-equiv="refresh" content="3;URL='http://www.example.com/'" /> </head>
<!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>
页面移动
此页面已移至
您将在3秒内被重定向
尝试一下:
<!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>
页面移动
此页面已移至
您将在3秒内被重定向
如果要使用php
执行此操作,可以使用header()函数发送新的HTTP头,但此头必须在任何HTML或文本之前发送到浏览器(甚至在声明之前)
或者你可以尝试类似的方法,包括重定向状态代码-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/' />
如果要使用php
执行此操作,可以使用header()函数发送新的HTTP头,但此头必须在任何HTML或文本之前发送到浏览器(甚至在声明之前)
或者你可以尝试类似的方法,包括重定向状态代码-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/' />
最快的方法是不通过向他们显示重定向消息来延迟他们。最快的方法是不通过向他们显示重定向消息来延迟他们。很好,但我在两分钟前回答了完全相同的问题,聪明的家伙。@mightyport:我没看到你的答案,它还没有加载。顺便说一句,我正在编辑我的答案。很好,但两分钟前我的答案完全相同,聪明的家伙。@MightyPork:我没有看到你的答案,它还没有加载。顺便说一句,我正在编辑我的答案。