I am trying to get Laravel 5 (5.1.31) to return a http status response of 404 when a page is not found. I have tried several things and it always returns 200.
In my controller I have this:
else
{
header('HTTP/1.0 404 Not Found');
return view('errors.404);
}
I have also tried:
else
{
http_response_code(404);
return view('errors.404);
}
and
else
{
abort(404, 'Page not found');
}
I also tried putting this in the 404.blade
@inject( 'response', 'Illuminate\Http\Response' )
{{ $response->status(404) }}
No success. No matter what I try, Laravel returns 200. How do I get it to return 404?