How to do Custom URL-rewrite


I have a table "user" in my database with the following attributes:

  1. Id (is unique)

  2. Username (is unique)

  3. Description

I want to rewrite my URLs from "" to just "".

How do I do it without rewriting the URL per Hand in my views?

Right now 99% of my links are created via:

CHtml::link('Link Text',array('controller/action','param1'=>'value1')); 

I don’t care about the URL parsing for now.



Create a rule in your CUrlManager settings and CHtml::link will automatically use it to generate the new Links.

from CHtml::link:

for "".

you need a rule like

'<username:\w+>'=> 'controller/action'