Apache服务器:
修改 :apache\conf\extra\httpd-multilang-errordoc.conf 文件
如下所示,修改404 对应文件即可
ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
ErrorDocument 410 /error/HTTP_GONE.html.var
ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var
404文件在如下路径下:
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、重启nginx
5、此时访问不存在url即跳转到自定义404页面