【问题标题】:Laravel route group page redirects to homeLaravel 路由组页面重定向到主页
【发布时间】:2016-05-03 08:22:55
【问题描述】:

我已经安装了 Laravel 并设置了身份验证,我还创建了一个这样的路由组:

// users that want to access test route should be logged in. 
Route::group(['middleware' => ['web', 'auth']], function () {
    Route::get('first', function () {
        return 'first';
    });
});

问题是当我像这样访问路由时:

http://localhost/first

我可以看到我的“第一条”消息,但是当我刷新同一页面时,laravel 会将我重定向到:

http://localhost/home

我无法解决这个问题,我已将我的第一条路线移出路线组,现在一切正常。如果我使用authweb 中间件将其保留在路由组中,则它不起作用。

【问题讨论】:

    标签: laravel routes middleware


    【解决方案1】:

    尝试删除web中间件if you're using 5.2.27 and higher

    【讨论】:

    • 是的。谢谢它解决了我的问题。我已将代码更改为 Route::group(['middleware' => ['auth']], function ()
    猜你喜欢
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 2018-06-20
    • 2019-02-01
    • 2023-04-02
    • 2016-03-23
    • 2020-05-26
    • 2019-10-26
    相关资源
    最近更新 更多