Magento Admin URL Changed – Fix 404 Error After Logging In

adminadminhtmllocal.xml

I changed the admin URL in app/etc/local.xml. Now, a 404 appears straight after logging in to this custom URL instead of dashboard (includes 'noRoute' in the URL). There is no problem with the admin section after the first page, so no need to revert to the default admin URL.

When I run select * from m_core_config_data where path like '%admin/%'; the only row returned is irrelevant (admin/dashboard/enable_charts)

The user(s) logging in have full administrator roles.

There is a function within Mage_Adminhtml_IndexController that appears to be relevant.

/**
* 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)
    $session->setIsFirstPageAfterLogin(true);
    }
    $this->_redirect($url);
}

If you search for getStartupPageUrl, you find the function in Mage_Admin_Model_User

/**
* Find admin start page url
*
* @return string
*/
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();
}

Could one of these functions help to show the dashboard on the first screen after log in?

Best Answer

I used the solution here which itself referenced a magentocommerce.com post that now just redirects to that website's homepage (http://www.magentocommerce.com/boards/viewthread/71668/).

In app/design/adminhtml/default/default/template/login.phtml

I changed

<form method="post" action="" id="loginForm">

to

<form method="post" action="<?php echo $this->getUrl('adminhtml') ?>" id="loginForm">
Related Topic