在thinkphp框架中添加404頁(yè)面的方法

2013-02-18 09:55:50來(lái)源:linuxde作者:

最近在用thinkphp框架完成了一個(gè)項(xiàng)目,需要在項(xiàng)目中添加404頁(yè)面,在網(wǎng)上搜索了在thinkphp框架中添加404頁(yè)面的方法,在這里記錄一下。

最近在用thinkphp框架完成了一個(gè)項(xiàng)目,需要在項(xiàng)目中添加404頁(yè)面,在網(wǎng)上搜索了在thinkphp框架中添加404頁(yè)面的方法,在這里記錄一下。

第一步:

在Lib/Action文件夾下創(chuàng)建EmptyAction.class.PHP

<?php
class EmptyAction extends Action {
function _empty(){
header("HTTP/1.0 404 Not Found");
$this->display('empty:index');
}
// 404
function index() {
header("HTTP/1.0 404 Not Found");
$this->display('empty:index');
}
}

第二步:

修改Lib/Action文件夾下所有的Action文件,在所有的控制器文件中加入如下代碼:

function _empty()
{
header("HTTP/1.0 404 Not Found");
$this->display('empty:index');
}

第三步,

在Tpl/empty文件夾下創(chuàng)建404頁(yè)面index.html

關(guān)鍵詞:thinkphp404

贊助商鏈接: