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

Anthonynzube's avatar

Redirect after login

i'm using laravel 7. in previous laravel versions when i wanted to change the page i intend to redirect to, i just change this line in the LoginController.php file.

protected $redirectTo = '/home';

i would change the 'home' url to something else. Now i'm trying to so the same thing and i've already changed it to

protected $redirectTo = '/todos';

Still it redirects me to 'home'. Also, i already have the 'todo' route registered.

0 likes
5 replies
jlrdw's avatar

That should work, have you changed anything else. In my laravel 7 it works, but I have the exact out of the box authentication just like in the docs.

etiennedeschenes's avatar

In Laravel 7, it's in your RouteServiceProvider:

    /**
     * The path to the "home" route for your application.
     *
     * @var string
     */
    public const HOME = '/home';
Anthonynzube's avatar

@jlrdw What do you mean by 'changed anything else' because I have changed a lot of things.

jlrdw's avatar

Hard to say what's not working if you made many changes to the built-in Authentication, if you have highly customized it then without your code it's hard to see what's going on.

jlrdw's avatar

Another option is use the authenticated method from the trait and:

    public function authenticated(Request $request, $user)
    {
         return redirect('/todos');
    }

You can also put logic with if statements, check the role, and redirect to admin area if admin, user area if user.

Please or to participate in this conversation.