首先要做好你的出错页面(404.asp或404.php文件),并上传到虚拟主机的根目录(FTP连接后的Web目录)!
再到我们主站主机管理后台进行设置!(先有文件才能设置)
“用户后台”--左边菜单栏的产品管理中心管理自己产品“空间管理主机管理”--在中间位置就显示你购买的虚拟主机,点击操作下的“管理”--再在虚拟主机的控制面板左边菜单栏“自定义出错页”-- 提交 OK了
如果是虚拟主机中要设置404错误页面
请用动态页面asp或PHP,这样才能正确放回404错误信息,设置为html或htm返回的是200信息
在asp代码上加入:
<%Response.Status = "404 Not Found"%>
在PHP代码上加入:
<?php
header('HTTP/1.1 404 Not Found');
?>
就可以了
如PHP代码的404错误页面源码:
| <?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=http://www.158558.cn/"> <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> |
演示如 http://www.piis.cn/404.php
说明:代码中的content="1;URL=http://www.158558.cn/" 其中1为多少秒进行跳转,如果要马上跳转就设置为0,其中http://www.158558.cn/为需要跳转的页面一般修改为你网站的访问网址即可,这样就跳转到首页了!
ASP的404错误页面源码:
| <%Response.Status = "404 Not Found"%> |
说明:代码中的content="1;URL=http://www.piis.cn/" 其中1为多少秒进行跳转,如果要马上跳转就设置为0,其中http://www.piis.cn/为需要跳转的页面一般修改为你网站的访问网址即可,这样就跳转到首页了!
