How to fix 404 not found in Magento admin


When you log in Magento backend and just see a 404 page. I got this issue when I transferred a website for my client to a new server. It is weird that frontend is still working without problems. Fortunately, I turned on the System Log before I transfer so that I could see the following error message:

Recoverable Error: Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in YOUR_PATH\app\code\core\Mage\Core\Model\App.php on line 555 and defined in YOUR_PATH\app\code\core\Mage\Core\Model\Store.php on line 285

If you see the same issue, the following queries can help you solve the problem.

UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';

You have to log in phpmyadmin and paste these queries. After that, using FTP client to clear var/cache and var/session folders. Now, refresh the site and hope it is back. Good luck!