php创建自定义404页面

来源:互联网 发布:免费数据库有哪些 编辑:程序博客网 时间:2024/05/29 23:24

Apache服务器:

修改 :apache\conf\extra\httpd-multilang-errordoc.conf  文件如下所示,修改404 对应文件即可ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.varErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.varErrorDocument 403 /error/HTTP_FORBIDDEN.html.varErrorDocument 404 /error/404.htmlErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.varErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.varErrorDocument 410 /error/HTTP_GONE.html.varErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.varErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.varErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.varErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.varErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.varErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.varErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.varErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.varErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.varErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var404文件在如下路径下:apache\error\404.html其他错误文件修改方式同上。修改完成后,重启Apache服务器即可!!!

nginx服务器:

1、创建自己的404.html页面放在网站根目录下。即:网站代码根目录/error/404.html(测试时,不知道为什么必须创建error文件夹,直接把404页面放到根目录下失败)2、修改nginx.conf文件在http定义区域加入:fastcgi_intercept_errors  on;3、更改nginx.conf或虚拟主机的域名.conf在server区域加入(bitnami.conf):error_page  404  =  /404.html;4、重启nginx5、此时访问不存在url即跳转到自定义404页面
0 0
原创粉丝点击