How to change the default controller / action in the UrlManager ?
Page 1 of 1
Change default controller / action
#2
Posted 02 November 2009 - 02:13 AM
You can't change that in the urlManager, but what you can do of course is:
So when you request the index page, the controller "controller" with action "action" will be triggered.
To really modify the core defaults (site/index), you have to modify CWebApplication::defaultController and CController::defaultAction.
In config:
and in your controller:
I guess the first solution is what you're looking for?!
...
'components' => array(
'urlManager' => array(
'rules' => array(
'' => 'controller/action',
),
),
),
...
So when you request the index page, the controller "controller" with action "action" will be triggered.
To really modify the core defaults (site/index), you have to modify CWebApplication::defaultController and CController::defaultAction.
In config:
return array( 'defaultController' => 'test', ...
and in your controller:
class TestController extends CController
{
public $defaultAction = 'test';
public function actionTest()
{
}
}
I guess the first solution is what you're looking for?!
#4
Posted 02 June 2012 - 11:44 PM
Y!!, on 02 November 2009 - 02:13 AM, said:
You can't change that in the urlManager, but what you can do of course is:
...
'components' => array(
'urlManager' => array(
'rules' => array(
'' => 'controller/action',
),
),
),
...
I am a yii newbie...but i wanted to say that the above code worked for me after i added another key value pair to the urlManager array
...
'components' => array(
'urlManager' => array(
'urlFormat'=>'path', //<---------This line
'rules' => array(
'' => 'controller/action',
),
),
),
...
#5
Posted 12 June 2012 - 06:28 AM
Hello!
I have similiar question
if I type in url name of controller which not exists (let's say "sdf") then I get error:
can we do that if unexisted controller is requested then defaultcontroller is used ?
I have similiar question
if I type in url name of controller which not exists (let's say "sdf") then I get error:
Quote
Error 404
Unable to resolve the request "sdf".
Unable to resolve the request "sdf".
can we do that if unexisted controller is requested then defaultcontroller is used ?
Yii newbie
Share this topic:
Page 1 of 1

Help

This topic is locked












