2016-07-08 64 views

回答

5

最好的辦法是創建一個擴展現有UrlManager類即yii/web/urlManager.php

class customUrlManager extends yii/web/urlManager { 
.. code here 
} 

然後指定你的配置元素的類即frontend/config/main.php

'urlManager' => [ 
      'class' => '<name_space>/customUrlManager' 
      'enablePrettyUrl' => True, 
      'showScriptName' => False, 
      'rules' => [ 
       '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', 
       '<controller:\w+>/<action:\w+>' => '<controller>/<action>', 
      ], 
     ], 
+0

您是新的URL管理器類歡迎 –