this my controller file MyController.php
class MyController extends CController
{
/**
* Index action is the default action in a controller.
*/
public function actionIndex()
{
$this->printtablerecord();
$this->abc();
}
public function print(){
echo "print";
}
public function abc(){
echo "abc";
}
public function abc1(){
echo "abc1";
}
}
when i run this file domain.com/mypage/index.php call this controller.
but i want to run the domain.com/mypage/index.php/abc it’s return 404.
i want to run controller function with url.
when i run domain.com/mypage/index.php/mycontroller/functionname
that run my specific function using url.
how to write rules into main.php using urlManager?
this is my config/main.php
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'abc' => 'MyController/abc',
),
change
public function print(){
echo "print";
}
to:
public function actionPrint(){
echo "print";
}
and also you can hide index.php too:http://www.yiiframework.com/forum/index.php/topic/7803-how-to-remove-index-php-from-url/
You have to changes these function name as action. like abcAction,abc1Action,printAction
Read This http://www.yiiframework.com/doc/guide/1.1/en/basics.controller