http status code 404 - PHP: prevent direct access to page -


i have pages don't want users able access directly.

i have function came works:

function prevent_direct_access() {     if($_server['request_uri'] == $_server['php_self'])     {         //include_once('404.php');         header("location: 404.php");     } } 

this want, url not change content does. wondering if there need add tell search engines 404 , not index it. keep in mind not want url change though.

thanks!

don’t redirect send 404 status code:

header($_server['server_protocol'].' 404 not found', true, 404); exit; 

Comments