Redirect 404 or just 404 header

半城伤御伤魂 提交于 2019-12-04 08:31:24

Redirecting means "What you asked for is actually over here".

If it isn't found, then it isn't found. Don't redirect.

Output a 404 status code, and then an HTML document that explains that whatever was requested wasn't found. You can then suggest an onwards journey by, for example, providing links to the main sections of the site or performing a search based on keywords extracted from the URL.

(The practical consequences of redirecting are that the URL vanishes from the address bar which makes it hard to look at an think "Oh, I mistyped that one letter, I'll just change it" or to copy/paste it into a bug report, etc).

header("Status: 404 Not Found"); //FastCGI
include("404.php");
exit;

URI remains the user asked.

You should redirect to an error page, but be sure you set status to 404. The error page can give the user tools to continue, like a sitemap, search, an explanation of what they were trying to load, and a little verbiage, like "We're sorry, but the page you requested at was not found."

Better yet, make your 404 page a script and use it to log the error so that you can become aware of common ones and fix them. It can be a tool for you too.

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