You are not logged in.
Pages: 1
Hello!
What would be the best way to do sef urls?
I mean that if I have, for example, post controller with view action and post with id 10, I would have url like http://www.example.com/post/view/10.
But if I want to url be like http://www.example.com/post/my-article-title/, what I have to do? What would be the best way? Or Zend Framework way to do that?
Last edited by miika (2010-03-03 14:53:51)
Offline
Hey miika,
you could definitely do it, however you'll need to configure a special route. I would suggest something like:
/post/:title/:id
so it would become
http://www.example.com/post/my-article-title/10
this way, it would be easy to parse out the id with $this->_getParam('id');
alternatively, you could append it to the post title, explode() on '-', reverse the stack and array_pop the top or grab the last element in the array.
with Zend_Route, you can basically create any kind of url structure you want and route it to the PostController::viewAction();
good luck!
Offline
Pages: 1