Hello. It is necessary on page 404 to remove the redirect. Any page can open as site.ru/page and the redikert will be on site.ru/page/ This is implemented in the controller via $ this-> middleware ('redirect'); but it is necessary that 404 be opened as it is written, without a redirect - site.ru/page123 and opened, and not as now site.ru/page123/ middleware code:

public function handle($request, Closure $next) { if (!preg_match('/.+\/$/', $request->getRequestUri())) { return Redirect::to( preg_replace("/\s{2,}/",'/', $request->getRequestUri() . "/" ), 301); } return $next($request); } 

All this works well, but on page 404 it needs to be removed. If there is no data, then transfer it to 404, I do it like this:

  if (!$data) { App::abort(404); } 

How can I eliminate?

    1 answer 1

    If I understand you correctly, you need a separate 404 page and not a display of a page with an error along the wrong route, I do it like this:

    in the App \ Exceptions \ Handler file

    in the render method:

     if($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) return redirect('/404')); 

    Just do not forget to create a processing route 404.