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

killerbeast2017's avatar

Show Auth Login Page as default route

I created a fresh installation of Laravel and ran php artisan make:auth. The pages are successfully generated but I want to be directed to the Login Page as the default page. I did something like this in my route:

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

This does the job but doesn't seem to be the correct solution. Is there other better ways to achieve this?

0 likes
3 replies
Snapey's avatar

just make your homepage protected by adding the auth middleware to it.

Then the new user will try to access \ and be automatically redirected to login route.

4 likes
ohffs's avatar
ohffs
Best Answer
Level 50

I do that a lot and just wrap everything except the auth routes inside a group, eg :

Auth::routes();

Route::group(['middleware' => 'auth'], function () {

    Route::get('/', ...);
    Route::get('/something'....);

});

4 likes

Please or to participate in this conversation.