更改apache站点默认_如何更改找不到站点的默认404错误页面

更改apache站点默认

The apache’s default “404 Error not found” page seems ugly. And may some hosting service put theire ads in it. We can add some entry in .htaccess to change the defualt 404 error page. This method can also be used for some other error codes. A list of the server returned codes can be found in Table 1.

apache的默认“ 404 Error not found”页面看起来很丑。 也许某些托管服务会将其广告投放其中。 我们可以在.htaccess中添加一些条目以更改默认404错误页面。 此方法也可以用于其他一些错误代码。 表1中列出了服务器返回的代码。

It simply need to add the “ErrorDocument” command to the .htaccess file. The format is:

只需要将“ ErrorDocument”命令添加到.htaccess文件中。 格式为:

ErrorDocument code /dir/file.ext

or

要么

ErrorDocument code http://mydomain.name/dir/file.ext

For example:

例如:

ErrorDocument 404 /404.html

would cause any error code resulting in 404 to be forwarded to mydomain.name/404.html

会导致导致404的任何错误代码转发到mydomain.name/404.html

ErrorDocument 404 https://www.systutorials.com/p/404.html

would cause any error code resulting in 404 to be forwarded to https://www.systutorials.com/p/404.html

会导致导致404的任何错误代码转发到https://www.systutorials.com/p/404.html

For other error code such as 401 the method is the same. But not all the returned code should be forwarded. Most of the time, forwarding the error codes is enough.

对于其他错误代码(例如401),方法相同。 但并非所有返回的代码都应转发。 在大多数情况下,转发错误代码就足够了。

Table1: Server returned codes

表1:服务器返回的代码

Successful Client Requests
200OK
201Created
202Accepted
203Non-Authorative Information
204No Content
205Reset Content
206Partial Content
Client Request Redirected
300Multiple Choices
301Moved Permanently
302Moved Temporarily
303See Other
304Not Modified
305Use Proxy
Client Request Errors
400Bad Request
401Authorization Required
402Payment Required (not used yet)
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable (encoding)
407Proxy Authentication Required
408Request Timed Out
409Conflicting Request
410Gone
411Content Length Required
412Precondition Failed
413Request Entity Too Long
414Request URI Too Long
415Unsupported Media Type
Server Errors
500Internal Server Error
501Not Implemented
502Bad Gateway
503Service Unavailable
504Gateway Timeout
505HTTP Version Not Supported
成功的客户要求
200
201 已建立
202 公认
203 非权威信息
204 无内容
205 重设内容
206 部分内容
客户请求已重定向
300 多项选择
301 永久移动
302 暂时移动
303 查看其他
304 未修改
305 使用代理
客户请求错误
400 错误的请求
401 需要授权
402 需要付款(尚未使用)
403 禁止的
404 未找到
405 不允许的方法
406 不可接受(编码)
407 需要代理身份验证
408 请求超时
409 要求冲突
410 走了
411 内容长度要求
412 前提条件失败
413 请求实体太长
414 请求URI太长
415 不支持的媒体类型
服务器错误
500 内部服务器错误
501 未实现
502 错误的网关
503 暂停服务
504 网关超时
505 不支持HTTP版本

翻译自: https://www.systutorials.com/how-to-change-the-sites-default-404-error-not-found-page/

更改apache站点默认

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值