2

I created a Yii application in the webroot. I enabled the Gii module and modify the .htaccess to remove the index.php part in the url.

I also have the urlManager component defined in the config/main.php configuration file.

'urlManager' => array(
    'showScriptName' => FALSE,
    'urlFormat' => 'path',
    'rules' => array(
        '<controller:\w+>/<id:\d+>' => '<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
        '<controller:\w+>/<action:\w+>' => '<controller>/<action>'
        )
)

When I enter http://www.mydomain.com/gii in the browser, I get redirected to http://www.mydomain.com/gii/default/login.

Obviously, there is no matching url rules in the urlManager. Does this mean that when Yii cannot find any matching url rule, it will then start looking for a matching module?

bobo
  • 8,439
  • 11
  • 57
  • 81
  • ¿What is the problem?... ¿Is there a problem? The redirection to http://www.mydomain.com/gii/default/login was unexpected to you? ¿What did you expected? – Alfredo Castaneda Garcia Dec 25 '11 at 02:36
  • @Alfredo Castañeda García the problem is, `gii` is a module name, `default` is a controller name, and `login` is the action. `gii/default/login` still works even I don't have a rule pattern that matches it, this is where I feel strange about. – bobo Dec 28 '11 at 04:47

2 Answers2

4

bobo, yes, it does look like Yii starts looking through matching modules:

yii/framework/gii/GiiModule.php, Line 43
* http://localhost/path/to/index.php?r=gii
*
* If your application is using path-format URLs with some customized URL rules, you may need to add
* the following URLs in your application configuration in order to access GiiModule:
* <pre>
* 'components'=>array(
*     'urlManager'=>array(
*         'urlFormat'=>'path',
*         'rules'=>array(
*             'gii'=>'gii',
*             'gii/<controller:\w+>'=>'gii/<controller>',
*             'gii/<controller:\w+>/<action:\w+>'=>'gii/<controller>/<action>',
*             ...other rules...
*         ),
*     )
* )
* </pre>

Looks like it starts with the normal rules and then moves on down to trying additional modules (and their controller/actions) after that. Seems to be using the module ID (gii in this case) as the first part of it all.

On further research, yes, that's the case. See the Yii Module page for more info.

acorncom
  • 5,975
  • 1
  • 19
  • 31
0

What you mean?? Gii is a module and the URL is right you have the default because the defaultController proprerty in CWebModule is 'default' you can extend Gii and customize it if you want.

cherif_b
  • 26
  • 3