一:
首先建立一个错误页面,如404.php或404.asp 根据你空间支持asp代码还是php代码来定
404.php的参考写法:
| <?php header('HTTP/1.1 404 Not Found'); ?> <html> <head> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <meta http-equiv="refresh" content="1;URL=/"> <title>404 Not Found</title> <style type="text/css"> <!-- .t { font-family: Verdana, Arial, Helvetica, sans-serif; color: #CC0000; } .c { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: normal; color: #000000; line-height: 18px; text-align: center; border: 1px solid #CCCCCC; background-color: #FFFFEC; } body { background-color: #FFFFFF; margin-top: 100px; } --> </style> </head> <body> <div align="center"> <h2><span class="t">404 Not Found</span></h2> <h2><span class="t">你查找的页面不存在或转移请浏览本站首页</h2> <table border="0" cellpadding="8" cellspacing="0" width="460"> <tbody> <tr> <td class="c">The requested URL was not found on this server.</td> </tr> </tbody> </table> </div> </body> </html> |
404.asp的参考写法:
| <%Response.Status = "404 Not Found"%> <html> <head> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <meta http-equiv="refresh" content="1;URL=/"> <title>404 Not Found</title> <style type="text/css"> <!-- .t { font-family: Verdana, Arial, Helvetica, sans-serif; color: #CC0000; } .c { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: normal; color: #000000; line-height: 18px; text-align: center; border: 1px solid #CCCCCC; background-color: #FFFFEC; } body { background-color: #FFFFFF; margin-top: 100px; } --> </style> </head> <body> <div align="center"> <h2><span class="t">404 Not Found</span></h2> <h2><span class="t">你查找的页面不存在或转移请浏览本站首页</h2> <table border="0" cellpadding="8" cellspacing="0" width="460"> <tbody> <tr> <td class="c">The requested URL was not found on this server.</td> </tr> </tbody> </table> </div> </body> </html> |
二:
将404错误页面(404.asp或404.php)上传到网站的根目录
三:
建立一个.htaccess文件,.htaccess文件内加入代码:
| RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /404.asp [L] |
其中代码中的404.asp换为你自己上传的404错误页面名称(如404.php或404.asp),并将.htaccess文件上传到网站的根目录就可以了!
四:
有的用户不知道怎么建立.htaccess文件,在这里简单教下


![]()
这样就完成了.htaccess文件的建立
五:
404设置后的效果演示:http://www.piis.cn/404.asp
文章来源:
网络小编D
版权声明:
本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站立刻删除。
