How To Access The Action Within Controller

Hello Friends,

I have a default controller named SiteController with some actions in it like: index, aboutcompany etc

When I open my site in browser like: localhost/lucky

The index action is working properly.

On index.php (view) i made a link: echo CHtml::link(‘About Company’, array('site/aboutcompany));

When I click on the link an error appears: The requested url not found on this server.

None of the actions (sitecontroller) are workin except index.

Please suggest me the solution

How to you access aboutcompany page? I mean manually access it? But nevertheless, I have a suggestion.


CHtml::link('About Company', array('site/aboutcompany));


CHtml::link('About Company', array('/site/aboutcompany));

and make sure that in your site has actionAboutcompany.

I tried all these things but still its not working.

This is my controller file

I used your site controller and it is working properly, I added the following code to my /protected/views/index.php


/* @var $this SiteController */



<?php $this->beginWidget('bootstrap.widgets.TbHeroUnit',array(

    'heading'=>Yii::t('language','Welcome to')." ".Yii::t('language',CHtml::encode(Yii::app()->name)),

    'htmlOptions'=>array('style'=>'text-align: center'),

)); ?>

<!--<p>Congratulations! You have successfully created your Yii application.</p>-->

<?php $this->endWidget(); ?>


echo CHtml::link('About Company', array('site/aboutcompany'));


and gave me index.php?r=site/aboutcompany or index.php/site/aboutcompany link which is correct.

BTW: make sure that you aboutcompany.php is in /protected/views/site directory. Other than that I don’t see any issue.

Your solution works fine, but this index.php in url is creating problem. To access the page i have to make change in url. Links are not working for different views.

What do you mean that the view does not appear properly? Can you provide screenshot?

This is the Yii code for link:

echo CHtml::link('COMPANY', array('site/aboutcompany'));

By looks of it I believe that you enabled urlManager,can you provide the urlmanager settings?