2

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!

2
  • 1
    I don't know if it's the reason, but there is no regex in your route... try /developer/(test)/(test) Commented Sep 21, 2011 at 16:23
  • Thanks Frederik, but unfortunately adding a more regex to the route didn't help though Commented Sep 21, 2011 at 17:07

1 Answer 1

2

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+.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks emaillenin, I tried using a more explicit regex (as detailed in the modified question) and still no luck. Not sure why it won't match against anything

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.