Php 重定向到404页
我在PHP脚本中有以下代码:Php 重定向到404页,php,symfony1,http-headers,Php,Symfony1,Http Headers,我在PHP脚本中有以下代码: <?php if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); } // Other statements follow here echo 'Hello ther
<?php
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
{
die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
// Other statements follow here
echo 'Hello there ...'
它应该是:
header("HTTP/1.0 404 Not Found");
exit();
您需要放置exit()代码>以避免这种情况。我还想添加:仅头调用不会停止脚本执行,这就是为什么必须退出或死亡。