Indiahoma
2016-04-12, 10:51 PM
加下面的代码到你的public_html目录下的.htaccess文件。
ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml
你可能不希望访客访问到你的错误页,显然,浏览到错误页很让人不爽,那么你可以设置一下,当要访问错误页的时候自动跳转到首页,你可以把代码改成下面这样:
ErrorDocument 404 /index.html
如果浏览器不显示你自定义的错误页,可能是因为它们要求所显示的页面必须要大于 1KB 吧!
主要的错误页有以下这些,大家可以多了解一下:
Client Request Errors
400 – Bad Request
401 – Authorization Required
403 – Forbidden
404 – Not Found
405 – Method Not Allowed
406 – Not Acceptable (encoding)
407 – Proxy Authentication Required
408 – Request Timed Out
409 – Conflicting Request
410 – Gone
411 – Content Length Required
412 – Precondition Failed
413 – Request Entity Too Long
414 – Request URI Too Long
415 – Unsupported Media Type
Server Errors
500 – Internal Server Error
501 – Not Implemented
502 – Bad Gateway
503 – Service Unavailable
504 – Gateway Timeout
505 – HTTP Version Not Supported
如果你想要恢复系统默认的错误页,也很简单,只需要删除 public_html 目录下的错误页面就可以了。比如:
404.shtml
403.shtml
500.shtml
ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml
你可能不希望访客访问到你的错误页,显然,浏览到错误页很让人不爽,那么你可以设置一下,当要访问错误页的时候自动跳转到首页,你可以把代码改成下面这样:
ErrorDocument 404 /index.html
如果浏览器不显示你自定义的错误页,可能是因为它们要求所显示的页面必须要大于 1KB 吧!
主要的错误页有以下这些,大家可以多了解一下:
Client Request Errors
400 – Bad Request
401 – Authorization Required
403 – Forbidden
404 – Not Found
405 – Method Not Allowed
406 – Not Acceptable (encoding)
407 – Proxy Authentication Required
408 – Request Timed Out
409 – Conflicting Request
410 – Gone
411 – Content Length Required
412 – Precondition Failed
413 – Request Entity Too Long
414 – Request URI Too Long
415 – Unsupported Media Type
Server Errors
500 – Internal Server Error
501 – Not Implemented
502 – Bad Gateway
503 – Service Unavailable
504 – Gateway Timeout
505 – HTTP Version Not Supported
如果你想要恢复系统默认的错误页,也很简单,只需要删除 public_html 目录下的错误页面就可以了。比如:
404.shtml
403.shtml
500.shtml