Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

daSilva's avatar

Laravel 11 Auth Routes

Hi everybody. I'm building a website with Laravel. There will be different screens for admin and user here. In previous versions, I could define and use auth.php in the routes folder. But I couldn't do this in Laravel 11. I can't define it in bootstrap. Is there any other way?

0 likes
6 replies
hupp's avatar

@dasilva you can do it like create custom middleware and register in Kernel.php under $routeMiddleware array and inside routes/web.php

Route::group(['middleware' => ['auth', 'role:admin']], function () {
    // Your admin routes go here
});

Route::group(['middleware' => ['auth', 'role:user']], function () {
    // Your user routes go here
});

@dasilva let me know if you still face any issue on this.

daSilva's avatar

@hupp thanks but I know that. I was previously using web.php for user and auth.php for admin and I want to use it that way again.

Lopsum's avatar

Hey, are you using Breeze or Jetstream? Be the way, you can always define your own routing file and using then closure in the Bootstrap file :

->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
        then: function () {
            Route::middleware('auth')
                 ->prefix('auth')
                 ->name('auth.')
                 ->group(base_path('routes/auth.php'));
        },

cf. : https://laravel.com/docs/11.x/routing#routing-customization

1 like
daSilva's avatar

@Vable I am using laravel auth/ui. I will try this. I hope it works. Thank you.

daSilva's avatar

@Vable This is it, thank you. but after doing this, I get ERR_TOO_MANY_REDIRECTS error in all urls in auth.php.

puklipo's avatar

Same as breeze. Don't choose the difficult way.

// routes/web.php

require __DIR__.'/auth.php';

Please or to participate in this conversation.