【发布时间】:2012-11-30 10:28:31
【问题描述】:
我有 以下代码在顶部执行 301 重定向,没有任何空格,并且此代码上方没有任何内容,但它给出了错误,
Warning: Cannot modify header information - headers already sent by
<?php
require_once('../../config.php');
header("HTTP/1.1 301 Moved Permanently");
header("location: http://www.myapp.com/courses/mycourse-new.php");
?>
我尝试使用 ob_start,但没有成功。我已经为许多文件做了 301 没有任何问题。如何解决这个问题。
【问题讨论】:
-
注释掉
required_once时还有消息吗? -
如果这里没有空格,那么
config.php可能有... -
您使用 PHP4 是否有特殊原因(自 2008 年以来不再支持)?
标签: php http-headers http-status-code-301 php4