问题描述
所以我们都知道这些错误缺少控制器
或 CakePHP
可能引发的任何其他错误.
现在我的问题可能很简单,但是我找不到关于该主题的任何文档.
如果应该找到执行程序,我该如何重定向到未找到的 404
或 500执行文件
页面(这意味着我如何重定向到Costum页面)?/p>
在我的config/core.php文件中,我发现了这一点:
Configure :: write('Exception',array('handler'=>'ErrorHandler :: handleException','renderer'=>'ExceptionRenderer','log'=>真的));
但是我不确定我应该将其更改为什么?
Configure :: write('Exception',array('handler'=>'ErrorHandler :: handleException','renderer'=>'测试','log'=>真的));
创建文件Cake/Error/Test.php
<?php班级考试{公共功能__construct(Exception $ exception){header('Location:/'); die();}}
可以通过路由器防止的Missing Controller错误.创建最后一个路由器规则:
Router :: connect('/*',array('controller'=>'app','action'=>'e404')));
So we all know these Error missing controller
or any other error that CakePHP
can throw.
Now my question may be fairly simple but i could not find any documentation on the subject.
How do i redirect to a 404 not found
or a 500 execption
page (meaning how do i redirect to a costum page) if an execption should be found?
in my config/core.php i found this:
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'ExceptionRenderer',
'log' => true
));
However im not sure what i should change it to?
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'Test',
'log' => true
));
Create file Cake/Error/Test.php
<?php
class Test {
public function __construct(Exception $exception) {
header('Location: /');die();
}
}
Missing Controller error you can prevent with router. Create last router rule:
Router::connect('/*', array('controller' => 'app', 'action' => 'e404'));
这篇关于Cakephp发生错误时重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!