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

GiacomoM's avatar

Redirect if not logged

Hi, I have some route that need to be logged to be seen. This is the code of the routes:

Route::group(['middleware' => 'auth'], function() {
            Route::get('string, ['as' => 'user.add_event', 'uses' => 'UserController@addEvent']);
 });

It works, but the problem is that if the user is not logged, he is redirected to "login" route, which is not present, instead of being redirected to "auth\login" route.

How can I solve it?

Thanks.

0 likes
3 replies
kingpabel's avatar
Level 5

For change the redirect url go to app/Http/Middleware/authenticate.php and then you will found a handle method.In that handle method change the redirect url.

2 likes
mf123's avatar

@kingpabel in voyage admin panel i wanna redirect to login page if admin or any roles are not logged in . how can I do this

Please or to participate in this conversation.