near as I can tell, that behavior is normal.
I've been looking at the docs and the code and it seems as though the router will load the default controller/action on a url like /en/mmm
. The lang:en is valid but mmm
doesn't match a valid module or controller so the default route is used.
In the case of en/mmm/ccc
it does throw a 404 because in the absence of a valid module the route will be match against controller/action and because the values are not valid will result in a 404. I'm sure why this results in a 404 and an invalid controller just results in the default route being called.
This activity is demonstrated to degree in these examples from Default Routes:
// Assuming the following: $ctrl->setControllerDirectory(
array(
'default' => '/path/to/default/controllers',
'news' => '/path/to/news/controllers',
'blog' => '/path/to/blog/controllers'
) );
Module only: http://example/news
//if not valid module would attempt to match controller.
//if not valid controller would call default route
module == news
Invalid module maps to controller name: http://example/foo
controller == foo
Module + controller: http://example/blog/archive
module == blog
controller == archive
Module + controller + action: http://example/blog/archive/list
//all three must be valid or 404
module == blog
controller == archive
action == list
Module + controller + action + params:
http://example/blog/archive/list/sort/alpha/date/desc
module == blog
controller == archive
action == list
sort == alpha
date == desc
The following code excerpt seems to be the best example I find of where this behavior is demonstrated.
//excerpt from Zend_Controller_Router_Route_Module
if ($this->_moduleValid || array_key_exists($this->_moduleKey, $data)) {
if ($params[$this->_moduleKey] != $this->_defaults[$this->_moduleKey]) {
$module = $params[$this->_moduleKey];
}
}
unset($params[$this->_moduleKey]);
$controller = $params[$this->_controllerKey];
unset($params[$this->_controllerKey]);
$action = $params[$this->_actionKey];
unset($params[$this->_actionKey]);
foreach ($params as $key => $value) {
$key = ($encode) ? urlencode($key) : $key;
if (is_array($value)) {
foreach ($value as $arrayValue) {
$arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue;
$url .= self::URI_DELIMITER . $key;
$url .= self::URI_DELIMITER . $arrayValue;
}
} else {
if ($encode) $value = urlencode($value);
$url .= self::URI_DELIMITER . $key;
$url .= self::URI_DELIMITER . $value;
}
}
if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) {
if ($encode) $action = urlencode($action);
$url = self::URI_DELIMITER . $action . $url;
}
if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) {
if ($encode) $controller = urlencode($controller);
$url = self::URI_DELIMITER . $controller . $url;
}
if (isset($module)) {
if ($encode) $module = urlencode($module);
$url = self::URI_DELIMITER . $module . $url;
}
return ltrim($url, self::URI_DELIMITER);
}
Hope this helps.