Search code examples
yiiyii-componentsyii-url-manager

Yii links not working properly


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(CHtml::encode($izletiste->nazivIzletista),array("izletiste/show","grad"=>"Paris","naziv"=>"Some text", "id"=>$id)); ?>

The url I get is the following:

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

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

Error 404

The system is unable to find the requested action "Paris".

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?


Solution

  • Try tho change first rule like here:

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