All posts tagged administration

@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">