Richard Knop
Richard Knop

Reputation: 83755

How rewrite my URIs with Zend_Router

I am trying to create a Zend_Route in my application. Currently I have URIs like this:

/api/resource/index/id/123

And I would like to rewrite them with Zend_Router to:

/api/resource/123

How to do it?

Upvotes: 0

Views: 98

Answers (1)

Richard Knop
Richard Knop

Reputation: 83755

God I'm slow today. I have figured it out:

    $router = Zend_Controller_Front::getInstance()->getRouter();

    $route = new Zend_Controller_Router_Route(
        '/api/:controller/:id',
        array(
            'module'     => 'api',
            'action'     => 'index'
        )
    );

    $router->addRoute('resource', $route);

Upvotes: 1

Related Questions