网上有很多thinkphp的404页面制作方法,但大多太过繁琐不简便,很烦人,所以为大家分享了最便捷的404制作方法,如下。
在thinkphp的公共目录的config配置文件中增加配置项:
1
|
'TMPL_EXCEPTION_FILE' => 'Public/404.html' , |
在Public文件夹中创建404.html内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<!DOCTYPE html > <html> <head> <meta charset=utf-8" /> <title>404哟</title> <style type= "text/css" > body { background-color: #ECECEC; font-family: 'Open Sans' , sans-serif; font-size: 14px; color: #3c3c3c; } .demo{width:600px;margin:0 auto;} .demo p:first-child { text-align: center; font-family: cursive; font-size: 150px; font-weight: bold; line-height: 100px; letter-spacing: 5px; color: #fff; } .demo p:first-child span { cursor: pointer; text-shadow: 0px 0px 2px #686868, 0px 1px 1px #ddd, 0px 2px 1px #d6d6d6, 0px 3px 1px #ccc, 0px 4px 1px #c5c5c5, 0px 5px 1px #c1c1c1, 0px 6px 1px #bbb, 0px 7px 1px #777, 0px 8px 3px rgba(100, 100, 100, 0.4), 0px 9px 5px rgba(100, 100, 100, 0.1), 0px 10px 7px rgba(100, 100, 100, 0.15), 0px 11px 9px rgba(100, 100, 100, 0.2), 0px 12px 11px rgba(100, 100, 100, 0.25), 0px 13px 15px rgba(100, 100, 100, 0.3); -webkit-transition: all .1s linear; transition: all .1s linear; } .demo p:first-child span:hover { text-shadow: 0px 0px 2px #686868, 0px 1px 1px #fff, 0px 2px 1px #fff, 0px 3px 1px #fff, 0px 4px 1px #fff, 0px 5px 1px #fff, 0px 6px 1px #fff, 0px 7px 1px #777, 0px 8px 3px #fff, 0px 9px 5px #fff, 0px 10px 7px #fff, 0px 11px 9px #fff, 0px 12px 11px #fff, 0px 13px 15px #fff; -webkit-transition: all .1s linear; transition: all .1s linear; } .demo p:not(:first-child) { text-align: center; color: #666; font-family: cursive; font-size: 20px; text-shadow: 0 1px 0 #fff; letter-spacing: 1px; line-height: 2em; margin-top: -50px; } </style> <script type= "text/javascript" > function countDown(secs,surl){ var jumpTo = document.getElementById( 'jumpTo' ); jumpTo.innerHTML=secs; if (--secs>0){ setTimeout( "countDown(" +secs+ ",'" +surl+ "')" ,1000); } else { location.href=surl; } } </script> </head> <body> <div class = "demo" > <p><span>4</span><span>0</span><span>4</span></p> </div> <script type= "text/javascript" > countDown(5, '/' ); </script> </body> </html> |
这样就完成了,至于状态码当然是 404了,因为thinkphp默认不存在的页面返回404,大功告成!最后再向大家推荐一个源码社区名字叫原创源码库,不错的网站,或许能够帮到您!
以上就是小编为大家带来的thinkphp制作404跳转页的简单实现方法的全部内容了,希望对大家有所帮助,多多支持服务器之家~