I have the following code in a PHP script:
<?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 ...'
instead of echoing the message, I want to redirect the user to a 404 page. However, when I replace the die() statement with this one:
header("HTTP/1.0 404 Not Found");
A user running the script from a remote machine is able to see the message 'Hello there ...'
How can I get the page to redirect to 404 page for non-localhost requests for the script?
BTW, this snippet id from the dev environment front controller in the Symfony framework.