dongmangji0950 2013-11-08 16:11
浏览 30
已采纳

Cakephp重定向错误

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?

  • 写回答

1条回答 默认 最新

  • douche3244 2013-11-08 20:06
    关注
    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'));    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建