中山php|最优网络中山做网站 中山php建站

最优良人

Posts Tagged With: 404

Fleaphp访问出错返回404页面的方法

2011/08/07 at 16:29 » Comments (414)

配置文件里有项 : 'dispatcherFailedCallback' , 他用来设置当调度器失败时调用的方法。 应用很灵活, 举个例子, 当控制器或控制器动作不存在就跳到定制的404页面。 FLEA::setAppInf('dispatcherFailedCallback', 'onDispatcherFailed'); function onDispatcherFailed { redirect('404.html'); }   dispatcherFailedCallback的配置分2种情况,如果当前访问的控制器、动作不存:'dispatcherFailedCallback' => 'onDispatcherFailedCallback', 如果用户设置了RABC访问控制,访问无法访问的动作时:'dispatcherAuthFailedCallback' => 'onAuthFailedCallback', 上面onDispatcherFailedCallback、onAuthFailedCallback是出错的时候调用的函数,你可以在index.php种定义这2个函数就OK了。 例如: function onAuthFailedCallback($controller,$action) { redirect(url('Login','Index')); // 这里是验证失败时,让用户去登录 } more »