2015-03-13 54 views
0

我想隱藏url中的動作視圖我已經傳遞了一個參數title.The動作視圖完美地工作,但動作索引不會被執行,而是一個動作視圖纔會被調用。
例如:如果我要求a/view/yii它需要查看動作,但是當我呼叫a/index時,也查看動作被稱爲爲什麼如此?無法隱藏url中的動作

'a/<title:\w+>' => 'a/view', 
'<controller:\w+>/<action:\w+>' => '<controller>/<action>', 

回答

1

這是因爲/action/index匹配的模板'a/<title:\w+>'

可以模板之前,此路由添加額外的規則:

'a' => 'a/index', 
'a/<title:\w+>' => 'a/view', 
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',