Custom Error pages in Yii (403,404 etc)

Hi All,

I’ve looked everywhere for this and I can’t seem to find a solution. I have seen many posts on this forum regarding the issue however the solutions that are provided never seem to work for me.

Basically I’m wanting to have custom error messages for 403 and 404 errors, I’m not too fussed about others at this point.

I’ve read that all you need to do is remove the below code, create a “error403.php” file in the “views/system” folder and it should work, however I’m having no luck.




'errorHandler'=>array(

			// use 'site/error' action to display errors

			'errorAction'=>'site/error',

		),



I seem to be getting an error through stack trace and the below line is highlighted.

 "throw new CHttpException(403,$message);"   (I have attached the error page in this post)

Does anybody have any ideas what the problem could be?

Thanks a lot

Hi,

you have to add this code…then only it will take custom pages





if ($error = Yii::app()->errorHandler->error) {

            switch ($error['code']) {

                case 404:

                    $this->render('error404', array('error' => $error));

                    break;

                case 500:

                    $this->render('error500', array('error' => $error));

                    break;

            }

        }