Reputation: 911
I'm getting the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/content/89/11421189/html/notfound.php:2) in /home/content/89/11421189/html/notfound.php on line 4
In my file 'notfound.php', which uses the code below:
<!DOCTYPE html>
<?php//Line 2
ob_start();
header('Location:http://www.website.com/index.php?page=404.php', true, 302);
exit;
?>
<head>
</head>
<html>
</html>
Note that there is NO whitespace before the PHP tag, or AFTER it. No matter where I move it to (even if it's all on the same line), that line is the culprit in the error. What am I doing wrong here?
[EDIT] Note: If I move the PHP to before the DOCTYPE tag, navigating to this file gives me an error 403: forbidden. The location is fine, since I can copy/paste it into the address bar without issues. Can you not pass GET arguments through header()?
Upvotes: 0
Views: 92
Reputation: 2449
You can't output headers after anything has been output. The DOCTYPE is output before the header().
Upvotes: 6