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

rewucivep's avatar

How to redirect if user is not authenticated?

How to redirect the user to some page when they are not authenticated? They now have access to all routes. Please help

0 likes
1 reply
bobbybouwmann's avatar
Level 88

You can use the default auth middleware for that in your web.php file

Route::middleware('auth')->group(function(){
    // write your route here... 
});

Or for a specific route

Route::get('protected-area', 'YourController@index')->middleware('auth');
1 like

Please or to participate in this conversation.