custom url rewriting


i’m new in yii framework

i’m developping a website that sell a some products (PCs , cars, tables …) each product is affected to a subcategory and category, visitors of the website can list products by category or subcategory.

i would like to use friendy urls for listing pages

listing by category witch have id = 1 :

default url :

to become :

with pagination to become :

listing by sybcategory witch have id = 20 :

default url :

to become :

with pagination to become :

page showing product details

default url :

to become :

any one can help me how to transform this urls using yii urlmanager or .htaccess

and how to use createURL or createAbsoluteUrl with the new urls

thanks for your help

any help please ?

I’d like to advice you to change a bit your goal.

If you do like that, a category that unfortunately has the name of a controller or action will make a slug conflict.

Better to use discriminators, for example:

This can be achived with this rules:



Please, note that this url allows you to use letters, number and _ for category name, while - you will use for separate the part of url.

With such url you will not have problems.