laravel 4 public file 404 code example
Example 1: 404 json laravel
To do that, we need to add this logic to the app/Exceptions/Handler.php class:
use Illuminate\Database\Eloquent\ModelNotFoundException;
public function render($request, Exception $exception)
{
if ($exception instanceof ModelNotFoundException && $request->wantsJson()) {
return response()->json(['message' => 'Not Found!'], 404);
}
return parent::render($request, $exception);
}
Example 2: laravel login shows 404
#enable rewrite modules on apache2
sudo a2enmod rewrite