Router on Zend 1.12 hide controller and action

0

Hello, I want to make the user not see my controller and the action in ZF 1.12.

Ex:

 http://meusite.com/produtos/listar/item/iphone-5s-preto

I want it to look like this:

 http://meusite.com/iphone-5s-preto.html

You do not even need to have .html just get the product name direct or at least the action does not appear, you can only have the controller. I want to leave the url as small as possible.

    
asked by anonymous 28.04.2015 / 00:16

1 answer

1
  

Note that I do not understand anything from Zend, I just made a brief reading of the documentation, it may contain errors

I do not know how your system is (if the routes are "automated"), but you could try rewriting them using addRoute and Zend_Controller_Router_Route_Regex , for example:

$route = new Zend_Controller_Router_Route_Regex(
    '([a-zA-Z0-9\-]+)\.html',
    array(
        'controller' => 'archive',
        'action'     => 'show'
    )
);
$router->addRoute('archive', $route);

If you prefer to use a routing system per directory (it seems like your case), you will have to define a url type this /produto/nome-do-produto.html and use setControllerDirectory

$ctrl->setControllerDirectory(
    array(
        'produto' => '/produtos/listar/item/controllers',
        'blog'    => '/path/to/blog/controllers'
    )
);
    
12.06.2015 / 00:26