久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

Discuz! 官方交流社區(qū)

標(biāo)題: 404頁面,具體怎么設(shè)置 [打印本頁]

作者: 明軍    時間: 2023-4-28 21:08
標(biāo)題: 404頁面,具體怎么設(shè)置
DZ3.5  安裝了亮劍的套餐,有些情況下需要404頁面,具體該怎么設(shè)置,(試過網(wǎng)上的多種方式都不行,如下行所示)哪位老板具體介紹下404.HTML究竟怎么配置


1.首頁新建一個文本文件命名為 404.php,然后用文本編輯器打開,填入以下代碼,并保存;

  • <?php
  • define('CURSCRIPT', '404');
  • require './source/class/class_core.php';
  • C::app()->init();
  • $navtitle = "404提示"; // 這里修改404頁面標(biāo)題
  • include template('common/404'); // 這里是你的404頁面模版
  • ?>

[color=rgb(122, 160, 57) !important]復(fù)制代碼

將$navtitle = "404提示"這行代碼中的“404提示”修改為你的404頁面的標(biāo)題,保存之后將404.php上傳到你網(wǎng)站的根目錄

2.接下來用編輯器打開你的404的html文件(后綴為.html或者.htm),去掉head,body標(biāo)簽,只留下<body>與</body>中間的那段代碼,其他全去掉
然后在最上面一行加上{template common/header},在最下面一行加上{template common/footer},保存

3.然后上傳到你的服務(wù)器上的template\default\common目錄里,如果你不是用的默認(rèn)模板,記得將default改成你模板目錄名,

4.最后,apache修改服務(wù)器配置文件上的404頁面聲明,也就是把 ErrorDocument 404 /404.html改成ErrorDocument 404 /404.php,不同服務(wù)器修改教程大家自行去網(wǎng)上找,然后你就訪問一個你網(wǎng)站沒有的路徑,比如在你的域名后隨便打幾個字母,如http://bbs.itqu.net/errorpage就可以看到效果

最后再用HTTP返回碼查詢工具檢測一下HTTP狀態(tài),這里成功檢測出狀態(tài)碼為404

---------------------------------------------   華麗分割線  ---------------------------------------------------
如果是nginx,在配置文件里可以看到

[color=rgb(122, 160, 57) !important]復(fù)制代碼

就直接在根目錄放一個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>很抱歉,網(wǎng)頁不存在!</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>網(wǎng)頁不存在,即將跳轉(zhuǎn)新網(wǎng)址</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">若網(wǎng)頁未能自動跳轉(zhuǎn)新網(wǎng)址,請點(diǎn)擊下面按鈕進(jìn)行跳轉(zhuǎn)!</font><br /><br />
  •     <div class="button">
  •         <a  title="進(jìn)入新網(wǎng)址">進(jìn)入新網(wǎng)址</a>
  •     </div>
  • </div>
  • </body>
  • </html>

[color=rgb(122, 160, 57) !important]復(fù)制代碼

上面代碼可以在訪問不到的時候自動跳轉(zhuǎn)首頁!


作者: wonderful    時間: 6 天前
謝謝分享,受教了




歡迎光臨 Discuz! 官方交流社區(qū) (http://www.9999xn.com/) Powered by Discuz! W1.0