Blog

Magento Admin page – 404 Error Not found when customized Url backend name

@Note: the solution below is not for the moment 100% compatible with third party modules like GoogleBase. I will try to find an improved way. There is a note below for developer to help to find a better way. Thx for your feedback.

Note: a functionnal solution is provided at the end of this article thanks to Frank in the comments.

For those who meet a problem with their Magento backend after to have customized the url access (e.g. http://www.magento.com/backend/) thanks to the file /app/etc/local.xml. They can get an error page 404 – Page Not Found after to be logged. This situation exists only if you have activated the configuration Store Code into URL ( System > Configuration > Web > Url Options > Add Store Code to Urls – YES).

The solution is to tell to Magento to not use Store Code in url for our customized url backend. You just need to edit the file local.xml in the following way: {backend_customized_name} = backend in our exemple http://www.magento.com/backend/

Below an exemple of local.xml file:

<config>
 <global>
  ...
  <request>
   <direct_front_name>
    <{backend_name_customized} />
   </direct_front_name>
  </request>
 </global>
 <admin>
  <routers>
   <adminhtml>
    <args>
    <frontName><![CDATA[{nom_backend_personalisé}]]></frontName>
    </args>
    </adminhtml>
    </routers>
 </admin>
</config>

Replace only {backend_customized_name} by backend (in our example) or else. Then you won’t get anymore this 404 error for adminhtml modules.

@developers:
If you want to deep more about this subject, take a look in the file /app/code/core/Mage/Core/Controller/request/Http.php line 148. The problem comes from here.

if ($this->_canBeStoreCodeInUrl()) {
$pathParts = <a href="http://www.php.net/explode">explode</a>('/', <a href="http://www.php.net/ltrim">ltrim</a>($pathInfo, '/'), 2);
$storeCode = $pathParts[0];

if (!$this->isDirectAccessFrontendName($storeCode)) {
	$stores = Mage::app()->getStores(true, true);
	if ($storeCode!=='' && <a href="http://www.php.net/isset">isset</a>($stores[$storeCode])) {
		Mage::app()->setCurrentStore($storeCode);
		$pathInfo = '/'.(<a href="http://www.php.net/isset">isset</a>($pathParts[1]) ? $pathParts[1] : '');
	}
	elseif ($storeCode !== '') {
		$this->setActionName('noRoute');
	}
}
            }

Solution from Frank: A solution for this problem is to change the action of the login form.
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="http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/admin/" id="loginForm">
  • sudhir

    i have tried what you have said in the above example i have changed in the local.xml file but i was getting this error what i have to do again to get my site back.

    • sylvainraye

      Hi,
      it seems you have a bug in your code because you have an error report. Check the folder var/report of your installation and find the the correspondent file number
      You should see the source of your problem.
      Regards

      • sudhir

        Hello sylvainraye
        I am getting the following errors in my reports,
        Can you please help me out what are these erros for ?

        a:4:{i:0;s:65:”dbModel read resource does not implement Zend_Db_Adapter_Abstract”;i:1;s:1526:”#0 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelResourceDbCollectionAbstract.php(134): Varien_Data_Collection_Db->setConnection(false)

        #1 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelConfig.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(Mage_Core_Model_Resource_Website))

        #2 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelConfig.php(1380): Mage_Core_Model_Config->getModelInstance(‘core_resource/w…’, Object(Mage_Core_Model_Resource_Website))

        #3 E:wampwwwcurve_shoppingcartappMage.php(490): Mage_Core_Model_Config->getResourceModelInstance(‘core/website_co…’, Object(Mage_Core_Model_Resource_Website))

        #4 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelAbstract.php(208): Mage::getResourceModel(‘core/website_co…’, Object(Mage_Core_Model_Resource_Website))

        #5 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelAbstract.php(213): Mage_Core_Model_Abstract->getResourceCollection()

        #6 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelApp.php(608): Mage_Core_Model_Abstract->getCollection()

        #7 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelApp.php(466): Mage_Core_Model_App->_initStores()

        #8 E:wampwwwcurve_shoppingcartappcodecoreMageCoreModelApp.php(349): Mage_Core_Model_App->_initCurrentStore(”, ‘store’)

        #9 E:wampwwwcurve_shoppingcartappMage.php(683): Mage_Core_Model_App->run(Array)

        #10 E:wampwwwcurve_shoppingcartindex.php(87): Mage::run(”, ‘store’)

        #11 {main}”;s:3:”url”;s:1:”/”;s:11:”script_name”;s:10:”/index.php”;}

        Thanks and Regadrs,
        Sudhir

        • sylvainraye

          Check again your local.xml file, it misses information about your database.

          • sudhir

            thanks you so much for your suggestions sylvainraye. Now my site is back .what i have done is simply i have changed the name of cache file in var folder But again if i am going with mydomain /admin i was getting the same issue. What i have to do to get my admin panel back.

          • sylvainraye

            Remove the lines about direct_front_name in your local.xml and just change the value between the tags to admin or a custom value. The code presented here works on earlier version of Magento 1.7

          • Elmer Arguedas

            Hi.. I´m having the same 404 error.. I been reading for almost 4 hours and Im new at this.. It was working just fine.. All I did was some desig change and ran the cache refresh.. and then it threw me the error.. please help!! Im using 1.8

          • sudhir

            Yes dude i have done the same thing but my error is as it is, my error is not resolved.

          • sylvainraye

            send me via the contact form your detail and the local.xml content

          • sudhir

            2014-02-01T11:03:10+00:00 ERR (3): Notice: Undefined variable: _catgName in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecustomthis-month-offer.phtml on line 68

            2014-02-01T11:03:10+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 31

            2014-02-01T11:03:10+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-01T11:03:10+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-01T11:03:10+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-01T11:03:10+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            i am getting these kind of errors in my system.log file please help me out regarding these errors what i have to do.

          • sudhir

            hai

            i am having the errors like

            2014-02-18T06:31:55+00:00 ERR (3): Notice: Undefined variable: _catgName in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecustomthis-month-offer.phtml on line 68

            2014-02-18T06:31:55+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 31

            2014-02-18T06:31:55+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-18T06:31:55+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-18T06:31:55+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-18T06:31:55+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecalloutsleft_col.phtml on line 55

            2014-02-18T06:33:16+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatepage2columns-left.phtml on line 35

            2014-02-18T06:33:16+00:00 ERR (3): Strict Notice: Only variables should be passed by reference in E:wampwwwcurve_shoppingcartappdesignfrontenddefaultspacelabstemplatecustomnavigation.phtml on line 2

            these are been showing in my system.log file
            can you please help me out finding a solution for these errors.

          • sudhir

            hello,

            I am working out on checkout page.
            I had an issue on that page.
            I am entering all the details for the first two steps i.e.
            1)Checkout Method
            2)Billing Information
            But after step 2 it was not redirecting to step 3 .i.e. Billing information.
            it was been redirecting again to the main page
            Could you please help me out wit this issue.

  • vikas rao

    magento SQLSTATE[42000] [1044] Access denied for user to Database

    Hi,

    please visit “http://steeloffcuts.co.nz/”

    Before the admin was not opening. so I edited some code in varien.php

    and again i changed code of varien.php file to original code.

    after some time, when i tried to open frontend, frontend also did’t worked.

    Before It was working well. I did’t changed any username , password or

    database name in local.xml. but all of a sudden, now it’s not working.

    Please help me in finding solution.

    Thanks in advance.

    • sylvainraye

      Hi,
      if you have such a message, it means that you have a wrong configuration into your loca.xml. check twice. It’s also possible that you have a misspelled tag in local.xml or config.xml of the folder app/etc/.
      Hope it helps
      Regards

  • Sanket

    You are great developer
    After searching on internet almost 4 hours I got this article and found perfect for me.
    Thanks for sharing your knowledge.

  • Debasis Chakraborty

    nice article thanks…fixed the issue for my older version magento 1.5