Customized 404 not found with PHP

南楼画角 提交于 2019-12-08 02:34:34

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/4237722/customized-404-not-found-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!