Answer the question
In order to leave comments, you need to log in
In beforeAction , the NotFoundHttpException is displayed as an error, not a 404 page. Why?
In beforeAction , the NotFoundHttpException is displayed as an error, not a 404 page. Why?
How to display normally?
Answer the question
In order to leave comments, you need to log in
Are you sure you are throwing exceptions? The code below works great and returns 404
<?php
namespace backend\controllers;
use Yii;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
class SiteController extends Controller
{
public function beforeAction($action)
{
throw new NotFoundHttpException();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question