How do I remove index
from http://localhost/dashboard/index/create
I have my urlManager
setup like this:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
And this gives me clean URLs like this http://localhost/dashboard
where dashboard
is a module with a default controller named indexController
.
Now, the problem I am having is that I cannot access other actions of the module controller without first putting index
e.g If I want to call actionCreate
inside indexController
, I always have to say http://localhost/dashboard/index/create
.
Is there any way I can get rid of index
and just call it like this: http://localhost/dashboard/create
?
This is how my module is configured in main.php
:
'modules' => array(
...
'dashboard' => array(
'defaultController' => 'index'
),
...
),
Thank you in advance :-)
Try arranging your array like this (put the line beginning with dashboard under your urlManager component):
You can create
.htaccess file
for that: