Posted By

asterfr on 02/21/10


Tagged

url php router rewriting route zend


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

postNuKe


Zend Router simple extension through simple regex


 / Published in: PHP
 

You have to add this code in your Bootstrap

  1. /**
  2. * Add this in your bootstrap
  3. */
  4. protected function _initRoutes() {
  5.  
  6. $ctrl = Zend_Controller_Front::getInstance();
  7. $router = $ctrl->getRouter();
  8. //match every call on http://ZEND_ROOT/aZ2s-Ty9
  9. $route = new Zend_Controller_Router_Route_Regex('([a-zA-Z0-9]+\-[a-zA-Z0-9]+)',
  10. //dispatch this to the VController
  11. 'controller' => 'v',
  12. // iAction()
  13. 'action' => 'i'
  14. ),
  15. //send the captured value has the "e" parameters of the request
  16. 1 => 'e'
  17. )
  18. );
  19.  
  20. //give a name to your route and add it to the default router
  21. $router->addRoute('view',$route);
  22. }

Report this snippet  

You need to login to post a comment.