title: Laravel 5.4 | Custom Page for NotFoundHttpException
body: <p>I am trying to redirect the user to a custom 404 page in case of NotFoundHttpException in Laravel 5.4</p>
  
  <p>To do so, I added following piece of code in App\Exceptions\Handler.php file:</p>
  
  <pre><code>public function render($request, Exception $exception)
  {
      if ($exception instanceof NotFoundHttpException) {
          if ($request-&gt;expectsJson()) {
              return response()-&gt;json(['error' =&gt; 'Not Found'], 404);
          }
          return response()-&gt;view('404', [], 404);
      }
      return parent::render($request, $exception);
  }
  </code></pre>
  
  <p>For some reason this doesn't work. Can someone please point if I am doing something wrong here?</p>
  
  <p>Thanks!</p>