htaccess and Url rules - two questions

Hi.

I have two questions for you about Url Rules or htaccess file.

Now I have:


            'baseUrl' => '/',

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => [

			'/' => 'site/index',

			'ad/<id:\d+>' => 'ad/view',

]

And it works, when I type ad/NUMBER it displayed correctly advertisement, but I would like to show it like this:

ad/NUMBER/TITLE

how to do it?

And second question:

How to set the Url Rules for specific id?

for example:

I have ad/show?category[id]=1

How to change it to display the name of the category depending on the number ?

ad/show?category[id]=1 ----> cars

ad/show?category[id]=2 ----> house

etc.

Question 1.

Just add one parameter

‘ad/<id:\d+>/<slug>’ => ‘ad/view’,

Your action can be still just




function actionView($id) {

...

}



But when you create url you can use ‘slug’ key

Question 2

Sorry, have not understood