对于302 Found,即临时重定向,请执行以下操作:
header('Location: http://www.yoursite.com/home-page.html');
exit;
如果您需要永久重定向,又名:301 Moved Permanently,请执行以下操作:
header('Location: http://www.yoursite.com/home-page.html', true, 301);
exit;
有关更多信息,请查看PHP手册中的头文件Doc。另外,exit;使用时别忘了打电话header('Location: ');
但是,考虑到您正在进行临时维护(您不希望搜索引擎将您的页面编入索引),建议您返回503 Service Unavailable带有自定义消息的消息(即您不需要任何重定向):
<?php
header("HTTP/1.1 503 Service Unavailable");
header("Status: 503 Service Unavailable");
header("Retry-After: 3600");
?><!DOCTYPE html>
<html>
<head>
<title>Temporarily Unavailable</title>
<meta name="robots" content="none" />
</head>
<body>
Your message here.
</body>
</html>
exit这些标头之后的脚本