简体   繁体   中英

Customized 404 not found with PHP

I am using the following code to display a cutom 404 not found with PHP:

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include('404.php');
exit();

However, the default browser's 404 page shows up. What is the right code for producing 404 while including a PHP file?

Thanks,

Joel

However, the default browser's 404 page shows up. What is the right code for producing 404 while including a PHP file?

Some browsers (namely IE and Chrome) show their own 404 page when the size of the page that was output is less than 512 bytes.

Pad your output to go beyond that. I like to use some nice ASCII art .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM