Laravel 5.0自定义404不使用中间件 [英] Laravel 5.0 custom 404 does not use middleware

查看:63
本文介绍了Laravel 5.0自定义404不使用中间件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用中间件来解析模板的输出.这对所有页面都工作正常.

I'm using a middleware to parse the output of the templates. This is working fine for all pages.

但是,当我想显示404(为此获得一个自定义页面)时,它不会将其视为http请求(这是我的想法),因为它没有通过中间件.

However when I want to show a 404 (got a custom page for that) it doesn't treat it as a http request (that's what I think) since it doesn't go through the middleware.

我的问题是,如何让所有请求都通过中间件.

My question is, how to have ALL requests go through the middleware.

推荐答案

错误页面无法通过route.php.

The error pages don't go through the routes.php.

Kernel.php中,将中间件从$routeMiddleware阵列移动到$middleware阵列.

In Kernel.php move your middleware from the $routeMiddleware array to $middleware array.

此数组中的中间件将在每个请求上运行(已在5.1中进行测试).

Middleware in this array will run on every request (tested in 5.1).

这篇关于Laravel 5.0自定义404不使用中间件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆