I
I
itpeople2019-06-04 18:31:04
Laravel
itpeople, 2019-06-04 18:31:04

Why is laravel returning code 200 instead of 404?

Guys, good evening. Please tell me how to get the code 404 instead of 200 from laravel.
The handler says:

if ($this->isHttpException($e)) {
        switch ($e->getStatusCode()) {

            // not authorized
            case '403':
                return \Response::view('errors.403',array(),403);
                break;

            // not found
            case '404':
                return \Response::view('errors.404',array(),404);
                break;

            // internal error
            case '500':
                return \Response::view('errors.500',array(),500);
                break;

            default:
                return $this->renderHttpException($e);
                break;
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Chernyshev, 2019-06-04
@kayn23

Check the output for the error class. If my memory serves me, then for 404 the exception is Symfony\Component\HttpKernel\Exception\NotFoundHttpException

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question