Router in Zend 1.12 hide controller and action

Asked

Viewed 77 times

0

Hi, I want to make sure the user does not see my controller or the action in ZF 1.12.

Ex:

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

I want you to stay like this:

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

You don’t even need to have the . html just to have the name of the direct product or at least not to have the action, you can only have the controller. I want to leave the url as little as possible.

1 answer

1


Note that I do not understand anything of Zend, I did only a brief reading of the documentation, may contain errors

I don’t 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 route system by directory (it seems 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'
    )
);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.