我想在一年中使用Gii。我的第一个webapp的protected/config/main.php没有注释这一部分,按照Yii文档中的说明启用Gii (123.45.67.123是我试图访问的计算机上的公共IP地址):
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123456',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('123.45.67.123','127.0.0.1','::1'),
),
),我还在我的protected/ urlManager /main.php中启用了这个配置,方法是取消对以下内容的注释:
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),当我访问我的Yii站点时,例如www.example.org,基本的Yii页面可以正常加载。当我做www.example.org/gii时,我得到了404。当我访问www.example.org/index.php?r=gii时,我得到一个404。为什么找不到我的Gii页面?我使用的是CentOS 5.6。
发布于 2011-06-06 22:05:26
尝试:
http://www.example.org/index.php/gii
看起来你和我对url有同样的规则。如果http://www.example.org将你带到你的yii webapp主页,那么上面的链接应该是有效的。
你要去http://www.example.org/gii,这是不正确的。
发布于 2011-06-06 16:01:20
我在gii中使用这样的urlManager
'urlManager'=>array(
'urlFormat'=>'path',
'cacheID' => false,
//'caseSensitive' => true,
'showScriptName' => false,
'urlSuffix' => '/',
'rules'=>array(
'gii'=>'gii',
'gii/<controller:\w+>'=>'gii/<controller>',
'gii/<controller:\w+>/<action:\w+>'=>'gii/<controller>/<action>',
...而且它不会与其他站点页面的路由冲突
发布于 2011-06-07 07:45:25
你能在你的整个urlManager代码块中加入@briic.lv的代码吗?它应该可以工作,和我的差不多:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array( // remove gii for production:
'gii'=>'gii',
'gii/<controller:\w+>'=>'gii/<controller>',
'gii/<controller:\w+>/<action:\w+>'=>'gii/<controller>/<action>',
'site/index'=>'/',
'<controller:\w+>'=>'site/<controller>',
'<filter:(proj|dept)>/<id:\d+>'=>'site/',
),
'showScriptName'=>false,
),如果它仍然不起作用,您可能还需要发布/链接到完整的main.config文件。
https://stackoverflow.com/questions/6246329
复制相似问题