Laravel 6:禁用除 home 和 login 之外的所有访客路由

Den*_*ito 0 authentication routes laravel

我需要禁用 Laravel 中除“/”和“登录”页面之外的所有访客路由。

这有可能实现它 routes/web.php 吗?

tam*_*rat 5

是的。在您的routes/web.php文件中,确保在auth中间件组下定义受保护的路由。

路线/ web.php

Route::get('/', function() {
    // / route
});

Route::get('/login', function() {
    // login page
});

Route::middleware(['auth'])->group(function () {
    // define your routes here
    // they'll be protected
});
Run Code Online (Sandbox Code Playgroud)

官方文档