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

返回列表 發帖
查看: 824|回復: 1

[求助] 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 金幣 已有1人回答
回復

使用道具 舉報

14

主題

93

回帖

152

積分

漸入佳境

貢獻
0 點
金幣
39 個
QQ
沙發
發表于 5 天前 | 只看Ta
謝謝分享,受教了
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

  • 關注公眾號
  • 有償服務微信
  • 有償服務QQ

手機版|小黑屋|Discuz! 官方交流社區 ( 皖ICP備16010102號 |皖公網安備34010302002376號 )|網站地圖|star

GMT+8, 2025-7-1 16:09 , Processed in 0.044267 second(s), 12 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2025 Discuz! Team.

關燈 在本版發帖
有償服務QQ
有償服務微信
返回頂部
快速回復 返回頂部 返回列表