Hi All,
I have my site ready to be on production environment, so I have upladoed to the server all files and my surprise was when I fount out that some things doesn’t work!
Many links doesn’t find the correct url and I just don’t know why, I’m using modules and I don’t know if it’s a problem. For instance, I have the following CMenu:
$this->widget('zii.widgets.CMenu', array(
'id'=>'cause-menu',
'encodeLabel'=>false,
'activateItems'=>true,
'htmlOptions'=>array('class'=>'nav nav-list account-sidenav'),
'items'=>array(
array('label'=>'<i class="ico-eye-open"></i> Preview',
'url'=>array('/causes/cause/preview','id'=>$id),
'itemOptions'=>array('id'=>'preview-item'),
),
array('label'=>'<i class="ico-edit"></i> Edit Cause',
'url'=>array('/causes/cause/update','id'=>$id),
'itemOptions'=>array('id'=>'edit-item'),
),
array('label'=>'<i class="ico-picture"></i> Images',
'url'=>array('/causes/cause/image', 'id'=>$id),
'itemOptions'=>array('id'=>'images-item'),
),
array('label'=>'<i class="ico-chat"></i> Comments',
'url'=>array('/causes/causecomment/index','id'=>$id),
'itemOptions'=>array('id'=>'comments-item'),
),
),
));
The first three links, in the controller ‘cause’, works perfectly, but the link for the controller ‘causecontroller’ doesn’t work, showing the error:
Error 404
Unable to resolve the request "causes/causecomment/index/id/1".
This is what I have in my config/main:
'urlManager'=>array(
'urlFormat'=>'path','showScriptName'=>false, 'caseSensitive'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
//'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<module>/<controller>/<action>',
),
),
And in my .htaccess in my webroot:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I have read the follow documentation:
Using search engine and user friendly urls
Using custom url rule classes
And I don’t know why this is happening because it works in my localhost!!! this happens in other places in my site, not only in the CMenu, also in a button:
$this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'link',
'url'=>Yii::app()->createUrl('/causes/causecomment/create', array('id'=>$model->id)),
'type'=>'success',
'label'=>'Comment!',
'size'=>'mini',
));
I don’t know why it can’t resolve the url for a different controller than ‘cause’.
Could someone help me with this? it’s really frustrating, thanks in advance.