Answer the question
In order to leave comments, you need to log in
How to remove redirect in Laravel on 404?
Hello. You need to remove the redirect on the 404 page. Any page can open as site.ru/page and the redicert will be on site.ru/page/ This is implemented in the controller via $this->middleware('redirect'); but it is necessary that 404 opens as it is written, without a redirect - site.ru/page123 opens like that, and not as it is 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);
}
if (!$data) {
App::abort(404);
}
Answer the question
In order to leave comments, you need to log in
Well, check the 404 page on the same middleware.
Well, like:
if ($page !== 404) {
// редирект
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question