html - PHP - How can i make php to show webservers 404 error page on header 404? -
i using php scripting, , need throw "404 not found" status message. have tried this:
<?php header($_server['server_protocol']." 404 not found"); header("location: 404.html"); exit(); ?>
but it's redirecting user 404.html
page , don't think it's practice so. instead, keep user on same page accessed, throw 404 status code , show 404.html contents.
i have tried setting error page in rewrite rules, , it's working correctly. want php show 404 file's content along 404 status code.
i have tried doing:
<?php header($_server['server_protocol']." 404 not found"); exit();
but gives 404 status code , blank page. contents of 404.html or 404.php file.
use include
include file 404 error message in , set header 404. please make sure send header before outputting else.
<?php header($_server["server_protocol"]." 404 not found"); include("404.html"); exit(); // terminate script ?>
Comments
Post a Comment