「索引」我如何從http://localhost/dashboard/index/create
的Yii - 取下URL
刪除index
我有我的urlManager
的設置是這樣的:
'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>',
),
),
而這給了我乾淨的網址,這樣http://localhost/dashboard
其中dashboard
是模塊的默認控制器名爲indexController
。現在
,我遇到的問題是,我如果不首先把index
e.g訪問模塊控制器的其它動作。如果我想打電話給actionCreate
內indexController
,我總是不得不說http://localhost/dashboard/index/create
。
有什麼辦法可以擺脫index
,只是這樣調用它:http://localhost/dashboard/create
?
這是我的模塊是如何在main.php
配置:
'modules' => array(
...
'dashboard' => array(
'defaultController' => 'index'
),
...
),
預先感謝您:-)
這解決了我的問題,但現在我一直遇到如下錯誤:'錯誤404:找不到操作'儀表板/儀表板/創建'。這是副作用嗎?我稱之爲「http:// localhost/dashboard/create」這樣的動作,但我不知道如何在URL上使用2個「dashboard」。任何想法之前,我關閉此線程? – Sthe 2012-07-18 06:49:36
嗯,我不明白爲什麼會添加一個額外的儀表板。 .htaccess能做什麼嗎? – Ansari 2012-07-18 06:52:55
這是我在我的.htaccess:! 'RewriteEngine敘述上 的RewriteCond%{} REQUEST_FILENAME -f 的RewriteCond%{} REQUEST_FILENAME -d 重寫規則。 index.php' – Sthe 2012-07-18 07:19:33