【发布时间】:2011-06-05 22:27:44
【问题描述】:
我想在 Yii 中使用 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/config/main.php 中启用了 urlManager:
// 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。
【问题讨论】:
-
您是否启用了 .htaccess 文件和 mod_rewrite?
-
是的,.htaccess 和 mod_rewrite 在 Apache 端启用。
标签: php url-routing yii