Generating URLs by path
Yii allows you to not only route your URLs to different controller actions but also to generate a URL by specifying a proper internal route and its parameters. This is really useful because you can focus on internal routes while developing your application, and only worry about real URLs before going live.
Tip
Never specify URLs directly and make sure you use the Yii URL toolset. It will allow you to change URLs without rewriting a lot of application code.
Getting ready
Create a fresh Yii application using
yiic webappas described in the official guide and find yourprotected/config/main.phpfile. Replace therulesarray as follows:// application components 'components'=>array( … // uncomment the following to enable URLs in path-format /* 'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( '<alias:about>' => 'website/page', 'page/about/<alias:authors>' => 'website/page', 'page/<alias>...