How do i remove the model name from URL

Hi,

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.

/Tommy

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 www.example.com/item/2 would be re-written to www.example.com/itemDetail/2 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.

/Tommy

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',



Jonny