I have a series of urlManager rules that simplify my web application. For example, the vanilla application installer that comes with Yii creates the ‘page’ model and I redirect pages from /site/page/view/about to /about.
This works great, but I am not sure if Yii is capable of reading my rules to determine the best URL to create. Currently, createUrl will return the standard URL (/site/page/view/about) if I use the following code:
createUrl('/site/page', array('view'=>'about'))
Alternatively, using createUrl('/about') will link to the preferred URL correctly, but this does not seem as good practice as the first example. Also, using this in the CMenu function will not associate this link as the current active link.
Is there better practice to follow for this requirement? The alternative use of createUrl seems overly ‘hard coded’ and, as noted, doesn’t work logically with the system (determining the active page, etc).
Your rule
'<page:\w+>' => 'site/page/view/<page>'is incorrect. Use this (assuming you are using the default gii generated code) as the first rule