如何在找不到请求的页面时将用户定向到404页面 [英] how to direct the user to the 404 page when the requested page is not found

查看:95
本文介绍了如何在找不到请求的页面时将用户定向到404页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,



有一个项目,我目前正在研究php,html和css。问题是我创建了一个404页面,每次用户发送我的Web应用程序中不存在的页面时都需要显示该页面。我的问题是,我该如何实现呢?



提前致谢。

Morning,

There is a project that i am currently working on on php,html and css. problem is i have created a 404 page that needs to show up every time the user sends the page that does not exists within my web application. my question is , how can i implement that?

Thanks in advance.

推荐答案

<?php
header(


_SERVER [ SERVER_PROTOCOL]。 404未找到);
include( notFound.php);
?>
_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); include("notFound.php"); ?>





或编辑apache的httpd.conf :



or edit apache's httpd.conf:

ErrorDocument 404 /notFound.php


这篇关于如何在找不到请求的页面时将用户定向到404页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆