为什么在Zend框架1.12中为路由中的任何URL打开第一个操作/第一个路由

I have written the following code in bootstrap.php file

    protected function _initRoutes() {
     $routers = Zend_Controller_Front::getInstance()->getRouter();
     $adminadd = new Zend_Controller_Router_Route('/:cityadd/', array('module' => 'user', 'controller' => 'city', 'action' => 'add'));
$routers->addRoute('addcity', $adminadd);

     $routing = Zend_Controller_Front::getInstance()->getRouter();
     $adminedit = new Zend_Controller_Router_Route('/:cityedit/', array('module' => 'user', 'controller' => 'city', 'action' => 'edit'));
$routing->addRoute('edit-city', $adminedit);
    }

My project name is demo

In my browser when I give the URL http://localhost/demo/public/cityadd the page opened is add action page i.e,

View script for controller City and script/action name add

When I give the URL http://localhost/demo/public/cityedit also the page opened is add action page i.e,

View script for controller City and script/action name add

instead it must be redirected to View script for controller City and script/action name edit

Why the same page is opened or why the page is redirected to same action for any URL given

The problem is that you're using variables in your routes. Variables are preceded with a colon. A route consisting only of a variable will match pretty much anything.

Try writing your routes without the colon:

protected function _initRoutes()
{
    $routers = Zend_Controller_Front::getInstance()->getRouter();
    $adminadd = new Zend_Controller_Router_Route('/cityadd/', array('module' => 'user', 'controller' => 'city', 'action' => 'add'));
    $routers->addRoute('addcity', $adminadd);

    $routing = Zend_Controller_Front::getInstance()->getRouter();
    $adminedit = new Zend_Controller_Router_Route('/cityedit/', array('module' => 'user', 'controller' => 'city', 'action' => 'edit'));
    $routing->addRoute('edit-city', $adminedit);
}