码迷,mamicode.com
首页 > Web开发 > 详细

thinkphp 自定义404页面

时间:2015-08-20 14:58:42      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

一、

手册-》调试-》异常处理

技术分享

在公共config.php 中加入:

‘TMPL_EXCEPTION_FILE‘ => ‘/Public/404.html‘, //访问不存在的跳转 

url访问错误的时候,就会自动去跟目录下的Public文件夹 下找404.html

url错误事例:http://localhost/newsuning/index.php/Admidfdfdf    //写入错误的模版

二、

当访问不存在的控制器时 跳到404页面

1.新建一个控制器 EmptyController.class.php

<?php

namespace Admin\Controller;
header(‘Content-type:text/html;charset=utf-8‘);
use Think\Controller;

class EmptyController extends Controller{
    public function _empty(){
        $this->display("Public:404");  //访问不存在的控制器时
    }
}

2.在view模层 建立Public文件夹,里面放入404.html

 

thinkphp 自定义404页面

标签:

原文地址:http://www.cnblogs.com/rainblack/p/4744808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!