Back to Blog

Redirect to homepage after successful login in Magento

Published on 19 August 2015

On a current project, I had a requirement to redirect to the homepage once a user successfully logs in to their account. I tried a few plugins to no avail, so had a go doing it myself. Obviously Magento by default, redirects to the customers Account page although there is a setting in the admin to turn this off. However, this resorts back to redirecting the user to the previous page, ie the referred page.

To redirect to the homepage takes a few more steps, but here’s how I did it.

Go to
admin > System > Configuration > customer configuration > Login Options >

and set “Redirect Customer to Account Dashboard after Logging in” to No.

Then open
\app\code\core\Mage\Customer\controllers\AccountController.php

Look around line 193:
Mage::helper('customer')->getAccountUrl()
is the redirection url to customer dashboard. Change this to your desired URL.

So, for example, you can change it from this:

$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());

To this:
$session->setBeforeAuthUrl(Mage::getBaseUrl());

…which will redirect your customers to homepage after a successful login.

Hope this helps!

Redirect to homepage after successful login in Magento | Phil Owen