AFAIK, in a route, you can't reference the url's query-string content, just its request path. But you could do the following:
Add a route that maps the old url to a redirect action:
$router->addRoute('view-test-redirect', new Zend_Controller_Router_Route_Static(
'view_test.php',
array(
'module' => 'test',
'controller' => 'index',
'action' => 'view-test-redirect',
)
);
Also, add a route representing your "real" action:
$router->addRoute('view-test', new Zend_Controller_Router_Route(
'view/test/:user',
array(
'module' => 'test',
'controller' => 'index',
'action' => 'view-test',
)
);
The action name view-test-redirect
corresponds to the action below:
public function viewTestRedirectAction()
{
$user = (int) $this->_getParam('user', null);
if (!$user){
throw new \Exception('Missing user');
}
$this->_helper->redirector->goToRouteAndExit(array('user' => $user), 'view-test');
}
Then your view-test
action can do things in the expected way:
public function viewTestController()
{
$user = (int) $this->_getParam('user', null);
if (!$user){
throw new \Exception('Missing user');
}
// Read db, assign results to view, praise unicorns, etc.
}
Not tested, just brain-dumping to demonstrate the idea.