www.gusucode.com > .htaccess文件在线生成器 2.0源码程序 > htaccessedit_2.0/htaccess/htaccess-404.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh" xml:lang="zh"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>通过htaccess 404自定义错误页面</title> 
<meta name="Keywords" content=".htaccess,htaccess,404,自定义,错误,页面" /> 
<meta name="Description" content="这个问题难不倒万能的htaccess,通过htaccess定义404错误可谓是小菜一碟,并且其它的错误类别也可以依葫芦画瓢。" /> 
<meta http-equiv="Content-Style-Type" content="text/css" /> 
<meta http-equiv="Content-Script-Type" content="text/javascript" /> 
<link rel="stylesheet" href="share/css/top_cn.css" type="text/css" /> 
</head>
<body onload="showElement('naviFileList')">
<div id="wrapperAll">
<h1><a href="index.php"><img src="share/images/common_files/logo_cn.gif" alt=".htaccess Editor" width="300" height="60" /></a></h1>
<ul id="globalNavi"><li id="siteHome">
<?php include"menu.php"; ?>
</li></ul> 
<ul id="sbs">
<?php include"share.php"; ?>
</ul>
<H2 align=center>htaccess 404错误页面的自定义</H2>
<div id="google">
<?php include"adsense.php"; ?>
</div>
<P align=left>估计所有类型的页面里,404错误页面是见得最多的一个页面了,冷不防出现个冰冷的404,用户体验非常差,也会给SEO带来不好的影响。一个好的404错误页面不仅可以引导用户至正确的页面,也会给人一种赏心悦目的感觉。另外,也可以通过<A href="htaccess-301.php" target=_self>301重定向</A>来更好的解决该页无法找到的问题。</P>
<P align=left>如果网站建立不久,就出现了什么改版、换程序等等,会在搜索引擎中产生大量的无效页面,如果不及时处理,很可能使你的站在搜索引擎中降低地位。众所周知,在Windows IIS里面,可以直接通过管理工具自定义错误文档,但这在Apache下如何实现呢?如果你用的是虚拟主机,无法自己定义,又该如何实现呢?</P>
<P align=left>这个问题难不倒万能的htaccess,通过htaccess定义404错误可谓是小菜一碟,并且其它的错误类别也可以依葫芦画瓢。</P>
<P>一般来说,有两种方法可以自己定义404错误页面,一种是通过空间控制面板,这种方法简单易行;另一种是自己建立htaccess文件,写入定义:</P>
<P>&nbsp;<FONT color=#993300>ErrorDocument 404 http://www.kuphp.net/404.html</FONT></P>
<P align=left>该行代码即定义404错误为404.html这个页面。其中404为错误代码,后面的网址为出现错误时需要返回的页面。我们非常建议使用完整地址,这样会减少出错的几率。另外,还有很多常用的其它错误代码也可以自己定义,如:</P>
<P align=left>400 - Bad request 错误的请求<BR>401 - Authorization Required 需要认证<BR>403 - Forbidden directory 禁止访问<BR>404 - Page not found 无法找到该页<BR>500 - Internal Server Error 内部服务器错误</P>
<P align=left>按照以上的格式添加进去即可。如果按照以上方法出现错误,可能是文件保存编码的问题。因此,我们建议您使用我们的工具来替您全自动完成这项工作,或者使用notepad2来编写该htaccess文件。</P>
 </div> 
<!--wrapperAll--> 
<div id="footer">
<?php include"footer.php"; ?>
</div><!--footer-->
</body>
</html>