使用Zend_Controller_Router_Route和URL视图助手时出现urlencode()错误

I am using the standard router in Zend Framework to route most URLs in the system.

For one particular URL, I want to access it via a controller alias (in addition to the real controller)

For example.

Actual URL:

/mymodule/mycontroller/myaction/*

Alias URL:

/mymodule/mycontrolleralias/myaction/*

mycontrolleralias is not a real controller, but I want any requests to it to route to mycontroller (query params and all)

To do this, I have tried to setup this route:

$router->addRoute('controlleralias', new Zend_Controller_Router_Route(
    ':module/mycontrolleralias/:action/*',
    array(
        'module'     => 'mymodule',
        'controller' => 'mycontroller',
        'action'     => 'myaction'
    )
));

But in my view helper if I try to create a URL:

$this->view->url(array('sort' => array('param1','param2')));

I get an error:

urlencode() expects parameter 1 to be string, array given

#0 [internal function]: __lambda_func(Array)
#1 /library/Zend/Controller/Router/Route.php(398): urlencode(Array, false, true)
#2 /library/Zend/Controller/Router/Rewrite.php(441): Zend_Controller_Router_Route->assemble(Array, NULL, false, true)
#3 /library/Zend/View/Helper/Url.php(49): Zend_Controller_Router_Rewrite->assemble(Array)

If I remove the star (*) from my custom route, no error will occur - but the urls generated in my view are then not correct because they will not be matching the query parameters:

$router->addRoute('controlleralias', new Zend_Controller_Router_Route(
    ':module/mycontrolleralias/:action',
    array(
        'module'     => 'mymodule',
        'controller' => 'mycontroller',
        'action'     => 'myaction'
    )
));

I have also found that if I don't pass in an array for a parameter, it will not generate an error:

$this->view->url(array('sort' => 'param1'));

Unfortunatly I do need to pass in an array for 'sort' (as shown above)

Does anyone know what I'm doing wrong? Perhaps there is an easier way to achieve this?

I am using Zend Framework 1.9.0

I think you should do something like that,

$this->view->url(array('sort' => 'param1,param2'),'controlleralias');

Also parameters cannot be arrays since the are based to urlencode as this.