Jump to content
Larry Ullman's Book Forums

Yii Routes '<Controller:\W+>/<Id:\D+>'=>'<Controller>/View'


Recommended Posts

I have a slight problem


I want to be able to load items via name or numerical id, yii is already set to work with numerical id through




but what if i pass a unique string instead to the view page how could i get that to work for example:




I have tried to make some of my own customizations but they have failed to work and i received the following error message:


Error 404
The system is unable to find the requested action "babolat-aerodrive-2013-nadal-rafa-3".


Is there someone that may know how to deal with such a situation?

Link to comment
Share on other sites

After some peaceful mediation:




As you can see this will strictly work for only the item controller and will not interfere with others. I also used \S because this means not whitespace, if I use /w it will cover all word characters but not the hypen "-" which I need.


You also need to add pages in item you need to access in config/main.php routes otherwise the above route will always send you to the view page.




Have a nice weekend everybody!

Link to comment
Share on other sites


  • Create New...