D
D
Denis2012-03-20 21:52:05
Zend Framework
Denis, 2012-03-20 21:52:05

Zend Framework Router?

Good afternoon!
Tell me how to write a router for a request like site.ru/id123 , where 123 is a variable number.
If you need site.ru/id/123 then this option works:

new Zend_Controller_Router_Route('id/:id', array('module' => 'default', 'controller' => 'user', 'action' => 'profile'))

But for id123 it is not clear.
new Zend_Controller_Router_Route('id:id', array('module' => 'default', 'controller' => 'user', 'action' => 'profile'))

Like this, but it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2012-03-20
@newpdv

Use routers based on regular expressions

Route("id/id(\d+)", array(
    'module' => 'default',
    'controller' => 'user',
    'action' => 'profile',
    1 => 'id'
)

framework.zend.com/manual/ru/zend.controller.router.html#zend.controller.router.routes.regex is described in more detail here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question