0

如何indexhttp://localhost/dashboard/index/create

我有这样的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>',
     ),
 ),

这给了我这样的干净 URL http://localhost/dashboard,其中dashboard一个模块的默认控制器名为indexController.

现在,我遇到的问题是我无法访问模块控制器的其他操作,index如果我想在actionCreate里面调用indexController,我总是不得不说http://localhost/dashboard/index/create

有什么办法可以摆脱index并像这样称呼它:http://localhost/dashboard/create

这是我的模块的配置方式main.php

'modules' => array(
    ...
    'dashboard' => array(
        'defaultController' => 'index'
    ),
    ...
),

先感谢您 :-)

4

2 回答 2

3

尝试像这样安排您的数组(将在您的 urlManager 组件下以仪表板开头的行):

array(
  ...
  'components' => array(
    ...
    'urlManager' => array(
      ...
        'rules' => array(
          'dashboard/<action:\w+>' => 'dashboard/index/<action>'
      ),
    ),
  ),
);
于 2012-07-17T20:34:02.680 回答
0

您可以.htaccess file为此创建:

RewriteEngine on
RewriteBase /project_folder_NAME
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
于 2014-05-12T10:13:13.127 回答