所以我们都知道这些缺少 Controller 错误
或CakePHP
可能抛出的任何其他错误。
现在我的问题可能相当简单,但我找不到有关该主题的任何文档。
如果找到执行,我如何重定向到 404 not find
或 500 exeption
页面(意味着如何重定向到 Costum 页面)?
在我的 config/core.php 中我发现了这个:
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'ExceptionRenderer',
'log' => true
));
但是我不确定应该将其更改为什么?
最佳答案
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'Test',
'log' => true
));
创建文件 Cake/Error/Test.php
<?php
class Test {
public function __construct(Exception $exception) {
header('Location: /');die();
}
}
您可以使用路由器来防止缺少 Controller 错误。创建最后一个路由器规则:
Router::connect('/*', array('controller' => 'app', 'action' => 'e404'));
关于php - Cakephp 错误重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19863587/