How to do Custom URL-rewrite

Hi,

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 "mysite.com/user/view&id=2" to just "mysite.com/username".

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.

THX

Andreas

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

from CHtml::link:

for "mysite.com/username".

you need a rule like


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