Yii links are not working as expected

In my Yii application I defined rules in Yii’s urlManager as follows:


'urlManager'=>array(

            'urlFormat'=>'path',

            'showScriptName'=>false,

            'rules'=>array(

                'izletiste/<grad:\.*?>/<naziv:.*?>/<id:d+>'=>'izletiste/show',

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

                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

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

            ),

        ),

Now, when I want to create a link, I use the following construction:


<?php echo CHtml::link("Link text",array("izletiste/show","grad"=>"Paris","naziv"=>"Some text", "id"=>$id)); ?>

The url I get is the following:


mywebsite.com/izletiste/Paris/Some+text/21

But when I click on the link, I get the following error:

My question is why is that happening, why Yii doesn’t recognize that izletiste/show action should be called instead izletiste/paris, and how to fix this?

I think you forgot the NAZIV and ID backslash. You can try this:


                'izletiste/<grad:\.*?>/<naziv:\.*?>/<id:\d+>'=>'izletiste/show',

After changing my route rules, and adding backslash, the issue remains.

Does it work if you remove the question marks?

I changed my rules to:


'rules'=>array(

                                'izletiste/<grad>/<naziv>/<id:\d+>'=>'izletiste/prikazi',

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

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

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

			),

and it works.

Now can someone explain me what is the difference between


<grad:\.*?>/<naziv:\.*?>

and


<grad>/<naziv>/

http://www.yiiframework.com/doc/guide/1.1/en/topics.url#using-named-parameters