문제

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, 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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top