How do i remove the model name from URL


I have got a url that currently looks like /itemDetail/1

ItemDetail being the models name, ideal what I’d like to do is make it something a bit cleaner like: /item/location/title

I have read the docs on url rewriting, but I was still unsure how to do this, could anyone offer some guidance to a newbie please? :)

You probably should read more about how a route is assembled.

Hint: ControllerID

Edit: If still in doubt, tell us more about the particular url.


Hello Tommy,

Well I thought that by using the rules inside the urlManager would allow me to change the url pattern.

What I tried was:

'item/' => 'itemDetail/View'

I thought that this would at least be a start in that would be re-written to internally and displayed.

This is sadly wrong, where am going wrong?

Thanks for your help so far :slight_smile:

Read more here about URL management.

Next: also show your url manager config and details about usage and what problem you encounter.

Edit: and don’t forget to search the forum, there’s plenty of url management examples.


You seem to be ignoring the ‘id’ parameter. ;)

Thanks for your help Tommy :slight_smile:

This is how I did it in case anyone else finds this helpfull

'items/<id:\d+>' => 'ItemDetail/View',