Magento admin dashboard 404 with multiple store

Exactly what is says in the title. When you have multiple store views or store groups you login to the admin and instead of the dashboard you get a 404 panel (in the main admin content section – the same thing you get when you install a module and don’t logout/login again);

magento-login-404

This happens irrespective of whether you add the store codes to the URLs in System -> Configuration -> General -> Web. Although, if you logout and log back in again it doesn’t happen which makes me think it is also related to the cookie expiration.

This is one of those really annoying ones where I knew I’d solved it before but when it happened again I had to get back onto Google because I’d forgotten what the fix was. D’Oh. So a blog post to help me and anyone else.

franckm in this post on the Magento forums is the answer – http://www.magentocommerce.com/boards/viewthread/71668/

File is in app/design/adminhtml/default/default/template/login.phtml.

Replace the line

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

with

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