【发布时间】:2015-08-01 16:26:29
【问题描述】:
我有一个相当复杂的应用程序,它使用了自定义身份验证中间件。我有一个这样的路由组:
Route::group(['prefix' => 'auth', 'middleware' => 'auth'], function() {
Route::get('/', function() {
echo 'private';
});
Route::group(['prefix' => 'public'], function() {
Route::get('/', function() {
echo 'public';
});
})
});
现在auth 中间件将重定向所有未通过身份验证的请求。带有auth 前缀的主组已通过身份验证。但是,即使用户未通过身份验证,我也希望可以访问组 public。
所以:
http://example.com/auth < must be authenticated
http://example.com/auth/some-sub-page < must be authenticated
http://example.com/auth/public < no need for authentication
那么有没有办法将'remove-middleware' => 'auth' 之类的内容添加到带有public 前缀的嵌套组中?还是我必须重组我的路线组?
【问题讨论】:
标签: php laravel laravel-5 laravel-routing middleware