国外主机商000webhost提供免费的空间,最大的好处是完全没有广告,这个或许大家都知道了。功能上嘛,个人感觉还是不错的,就是不能一次性上传大量文件。
里面有一个可以自定义404错误页面,可是一直一来在控制面板里面也没有找到这个选项。刚才在网上查了一些资料,总算可以自定义404错误页面了。
第一步:新生成error.php文件,代码如下:
<?php
$status = $_SERVER['REDIRECT_STATUS'];
$codes = array(
403 => array('403 Forbidden', 'The server has refused to fulfill
your request.'),
404 => array('404 Not Found', 'The document or file requested
was not found.'),
405 => array('405 Method Not Allowed', 'The method specified in
the Request-Line is not allowed for the specified resource.'),
408 => array('408 Request Timeout', 'Your browser failed to send
a request in the time allowed by the server.'),
500 => array('500 Internal Server Error', 'The request was
unsuccessful due to an unexpected condition encountered by the
server.'),
502 => array('502 Bad Gateway', 'The server received an invalid
response from the upstream server while trying to fulfill the
request.'),
504 => array('504 Gateway Timeout', 'The upstream server failed
to send a request in the time allowed by the server.')
);
$title = $codes[$status][0];
$message = $codes[$status][1];
if ($title == false || strlen($status) != 3) {
$message = 'Please supply a valid status code.';
}
echo '<p><h1>' . $title . '</h1></p>' .
'<p>' . $message . '</p>';
?>
第二步:新生成一个 .htaccess 文件,复制以下3行代码
ErrorDocument 403 /error.php ErrorDocument 404 /error.php ErrorDocument 500 /error.php
第三步:把以上新生成的2个文件上传到你的空间根目录下面。
注意:放在 public_html 目录的里面(根目录是public_html)
第四步:访问你的网站(访问你网站下的不存在的页面),是不是出现了404错误页面了?
搞定!哈哈
当然,你也可以自己定制要显示的404错误页面信息,下面是我自己网站的404错误页面
http://www.taochang/abcdefg/ 哈哈
? Copyright Birdol.Com 2006-2014.
继续阅读《000webhost主机上定制404错误页面》的全文内容...
分类: 技术分享 | Tags: | 添加评论(2)
最新评论:
- 2012-05-07 21:53:27 PM,crystal : 得不到金山认同的孩纸!
相关文章:
- Everything:速度最快的文件名搜索工具 (2013-02-10)
- 为什么要 禁用前面板插孔检测,机箱前面的耳机才能用? (2017-07-26)
- 面朝电脑,潇洒不再 (2012-12-18)
- 2016谷歌可用镜像地址(长期有效) (2014-08-17)
- 鼠标中键的妙用 (2015-03-14)
欢迎转载,请保留出处,谢谢!
我的微信
这是我的微信扫一扫
我的微信
微信号已复制
我的微信公众号
我的微信公众号扫一扫
我的公众号
公众号已复制

