Laravel中的重定向循环 [英] Redirect loop in laravel

查看:115
本文介绍了Laravel中的重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在组中使用Laravel过滤器之前?

How to use before filter in Laravel in a group?

Route::group(['before'=>'auth','domain' => 'm.domain.us'], function(){
    ...
    Route::get('/','PageController@index');
});

我以这种方式尝试过,如果我仅在组中使用域,则可以,但是我想使用身份验证过滤器 在该组中的所有页面上,因为它是管理员部分,当我输入'before' => 'admin'并收到错误消息:

I tried in this way, if I use only domain in group it works but I want to use auth filter on all pages in this group because it is admin section and when I entered 'before' => 'admin' and it gets an error:

此网页具有重定向循环.

This webpage has a redirect loop.

这里出什么问题了?

推荐答案

可能是因为您的登录路由位于::group-filter内部.
这意味着:如果用户已登录,程序也会在登录页面上进行检查.当然,用户不是-> Redirect::to('login') ...您有循环=)

Probably this occurs because your Login-Route is inside your ::group-filter.
This means: Program checks also on login page if user is logged in. Of course, the user is not -> Redirect::to('login') ... There you have your loop =)

这篇关于Laravel中的重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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