How To Achieve Directory Style Urls

I am trying to create a controller action to show a page that is nested in a heirarchy of other pages. When it comes to the url I initially built the action to work like:




public function actionView($slug)

{

    // get the page I need by it's unique slug

}



What I want to achieve however is a nested set of slugs like domain.com/page/view/tier-1-slug/tier-2-slug/tier-3-slug. I thought of saving the whole string in the database but thats really not a great idea and the urlManager doesn’t deal well with a get parameter with backslashes in it.

Any ideas?

you have 2 options:

  • either use pattern URL filters

  • or use CustomUrlRules.

Read more: http://www.yiiframework.com/doc/guide/1.1/en/topics.url