I want admin users to be redirected to the url they opened after login. They should get links to a custom module page in the admin area, like


Obviously, they will be redirected to the login page, unless they are already logged in.

How can I redirect them back to this page after login?

Secret keys in the URL are disabled and can stay that way.

Now they get the configured default page (default was Dashboard) instead.

  • ok, basially you want to redirect admin to redirect to your custom page instead of dashboard, after login, right ? Commented Sep 24, 2015 at 15:54
  • Nope, that would just be a setting. I want it to redirect to whatever URL was open before login.
    – Josef
    Commented Sep 24, 2015 at 15:58
  • I don't think you can do this out of the box. You will need to make a customization Commented Oct 14, 2015 at 14:40
  • 1
    Isn't this the default behaviour in Magento? If you try to go to an admin page you get redirected to the login page and after a successful login you go back to that page not the dashboard. Commented Oct 28, 2015 at 9:28
  • 1
    It is the default behaviour for the frontend. For the backend it takes you to the Dashboard. Maybe you could replicate it. The whole implementation is done in code/core/Mage/Customer/controllers/AccountController.php. Look for the getBeforeAuthUrl and setBeforeAuthUrl. Anyway, it isn't 5 minute job. Commented Nov 11, 2015 at 13:47

2 Answers 2


As all the comments stated before, its not out of the box. Here are some hints on where/what you may need to adjust:


public function getStartupPageUrl()
        $startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE);
        $aclResource = 'admin/' . $startupPage;
        if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) {
            $nodePath = 'menu/' . join('/children/', explode('/', $startupPage)) . '/action';
            $url = (string)Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode($nodePath);
            if ($url) {
                return $url;
        return $this->findFirstAvailableMenu();

I have never tried it but this seems to be the method called from


and there is the IndexAction that calls the above function. Since this is the admin, doing a rewrite of the Model will probably be easier.

 * Admin area entry point
 * Always redirects to the startup page url
public function indexAction()
    $session = Mage::getSingleton('admin/session');
    $url = $session->getUser()->getStartupPageUrl();
    if ($session->isFirstPageAfterLogin()) {
        // retain the "first page after login" value in session (before redirect)

So, modifying getStartupPageUrl() to have your URL seems very likely the best place to try this.

This is all theoretical, I have not tried it yet, but if you need a sample module, I can certainly run through this and provide it.

If every admin user will end up on the same page, its pretty easy to do, if there is some dynamic elements, it will be a bit harder to facilitate. Good Luck!


In Magento 1.9+ there is Mage_Admin_Model_Redirectpolicy. In here is getRedirectUrl:

 public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Request_Http $request = null, $alternativeUrl = null)
    if (empty($request)) {
    $countRequiredParams = ($this->_urlModel->useSecretKey()
        && $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME)) ? 1 : 0;
    $countGetParams = count($request->getUserParams()) + count($request->getQuery());

    return ($countGetParams > $countRequiredParams) ?
        $this->_urlModel->getUrl($user->getStartupPageUrl()) : $alternativeUrl;

As described in the function comment: "Redirect to startup page after logging in if request contains any params (except security key)"

Changing that return statement to always return the $alternativeUrl, solves the problem. Having said this, I'm not sure what other problems it causes (specifically in regard to security). Would need to dig deeper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.