时间:2011-04-11 点击: 次 来源:网络 作者:不详 - 小 + 大
国外主机商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错误页面 |
上一篇:PHP跳转代码实现一个网站空间绑定多个域名,建立多个网站
下一篇:QQ拼音九大隐秘功能惊喜大揭密