我在web浏览器中创建了一个Yii应用程序。我启用了Gii模块,并修改了.htaccess,以删除url中的index.php部分。
我还在config/main.php配置文件中定义了urlManager
组件。
'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>'
)
)
当我在浏览器中输入http://www.mydomain.com/gii
时,我被重定向到http://www.mydomain.com/gii/default/login
。
显然,urlManager
中没有匹配的url rules
。这是否意味着当Yii找不到任何匹配的url规则时,它将开始寻找匹配的模块?
bobo,是的,它看起来确实像Yii开始查找匹配的模块:
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>
看起来它开始与正常的规则,然后移动到尝试额外的模块(和他们的控制器/动作)之后。似乎是使用模块ID (gii在这种情况下)作为它的第一部分。
在进一步的研究中,是的,情况就是这样。
你是什么意思?Gii是一个模块,URL是正确的,你有默认值,因为CWebModule中的defaultController属性是'default',你可以扩展Gii并自定义它,如果你想。