返回列表 发帖
查看: 513|回复: 0

[求助] 404页面,具体怎么设置

1

主题

0

回帖

5

积分

初学乍练

贡献
0 点
金币
4 个
发表于 2023-4-28 21:08:35 | 显示全部楼层 |阅读模式
DZ3.5  安装了亮剑的套餐,有些情况下需要404页面,具体该怎么设置,(试过网上的多种方式都不行,如下行所示)哪位老板具体介绍下404.HTML究竟怎么配置


1.首页新建一个文本文件命名为 404.php,然后用文本编辑器打开,填入以下代码,并保存;

  • <?php
  • define('CURSCRIPT', '404');
  • require './source/class/class_core.php';
  • C::app()->init();
  • $navtitle = "404提示"; // 这里修改404页面标题
  • include template('common/404'); // 这里是你的404页面模版
  • ?>

[color=rgb(122, 160, 57) !important]复制代码

将$navtitle = "404提示"这行代码中的“404提示”修改为你的404页面的标题,保存之后将404.php上传到你网站的根目录

2.接下来用编辑器打开你的404的html文件(后缀为.html或者.htm),去掉head,body标签,只留下<body>与</body>中间的那段代码,其他全去掉
然后在最上面一行加上{template common/header},在最下面一行加上{template common/footer},保存

3.然后上传到你的服务器上的template\default\common目录里,如果你不是用的默认模板,记得将default改成你模板目录名,

4.最后,apache修改服务器配置文件上的404页面声明,也就是把 ErrorDocument 404 /404.html改成ErrorDocument 404 /404.php,不同服务器修改教程大家自行去网上找,然后你就访问一个你网站没有的路径,比如在你的域名后随便打几个字母,如http://bbs.itqu.net/errorpage就可以看到效果

最后再用HTTP返回码查询工具检测一下HTTP状态,这里成功检测出状态码为404

---------------------------------------------   华丽分割线  ---------------------------------------------------
如果是nginx,在配置文件里可以看到
  • #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
  •     error_page 404 /404.html;
  •     error_page 502 /502.html;
  • #ERROR-PAGE-END

[color=rgb(122, 160, 57) !important]复制代码

就直接在根目录放一个404.html
  • <!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">
  • <head>
  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  • <title>很抱歉,网页不存在!</title>
  • <style type="text/css">
  • body {margin: 0px; padding:0px; font-family:"微软雅黑", Arial, "Trebuchet MS", Verdana, Georgia,Baskerville,Palatino,Times; font-size:16px;}
  • div{margin-left:auto; margin-right:auto;}
  • a {text-decoration: none; color: #1064A0;}
  • a:hover {color: #0078D2;}
  • img { border:none; }
  • h1,h2,h3,h4 {
  • /*  display:block;*/
  •     margin:0;
  •     font-weight:normal;
  •     font-family: "微软雅黑", Arial, "Trebuchet MS", Helvetica, Verdana ;
  • }
  • h1{font-size:44px; color:#0188DE; padding:20px 0px 10px 0px;}
  • h2{color:#0188DE; font-size:16px; padding:10px 0px 40px 0px;}
  • #page{width:910px; padding:20px 20px 40px 20px; margin-top:80px;}
  • .button{width:180px; height:28px; margin-left:0px; margin-top:10px; background:#009CFF; border-bottom:4px solid #0188DE; text-align:center;}
  • .button a{width:180px; height:28px; display:block; font-size:14px; color:#fff; }
  • .button a:hover{ background:#5BBFFF;}
  • </style>
  • </head>
  • <body>
  • <div id="page" style="border-style:dashed;border-color:#e4e4e4;line-height:30px;background:url(sorry.png) no-repeat right;">
  •     <h1>网页不存在,即将跳转新网址</h1>
  •     <h2>The website is moving. It is about to jump to the new website. </h2>
  •     <meta http-equiv="refresh" content="1;url=http://bbs.itqu.net">
  •     <font color="#666666">若网页未能自动跳转新网址,请点击下面按钮进行跳转!</font><br /><br />
  •     <div class="button">
  •         <a  title="进入新网址">进入新网址</a>
  •     </div>
  • </div>
  • </body>
  • </html>

[color=rgb(122, 160, 57) !important]复制代码

上面代码可以在访问不到的时候自动跳转首页!

我知道答案 回答被采纳将会获得1 贡献 + 1 金币 已有0人回答
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2024-5-18 13:00 , Processed in 0.043049 second(s), 7 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2024 Discuz! Team.

关灯 在本版发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表