djs22
djs22

Reputation: 1156

Zend_Controller_Router_Route_Regex not working

I'm trying to use the Zend_Controller_Router_Route_Regex in an application but it doesn't seem to be working at all.

I've set up a very basic instance:

    $route = new Zend_Controller_Router_Route_Regex(
                        '/developer/test/(d+)',
    array('controller' => 'developer', 'action' => 'module','module'=>'topic')      
    );
    $router->addRoute('apiModule2', $route);

and the corresponding action:

public function moduleAction()
{
    $this->view->module = 'topic';
}

However, every time I visit localhost/developer/test/1, I get a No Route Matched exception.

I believe this is all set up properly because if I use the same exact code changing only Zend_Controller_Router_Route_Regex to Zend_Controller_Router_route and the match url to match against to 'developer/test/1' it all works perfectly.

Any ideas what could be going on?

Thanks!

Upvotes: 2

Views: 701

Answers (1)

Raj
Raj

Reputation: 22926

The correct route to match

http://localhost/developer/test/1

is

$route = new Zend_Controller_Router_Route_Regex(
                    'developer/test/(\d+)',
array('controller' => 'developer', 'action' => 'module','module'=>'topic')      
);

You should not have leading slash(before the developer) and d+ should be \d+.

Upvotes: 2

Related Questions