在http://www.yiiframework.com/doc/blog/1.1/en/prototype.scaffold教程之后,它提到向/blog/受保护的/config/main.php添加一些代码
return array(
......
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'pick up a password here',
),
),
);这是我为main.php编写的最后几行代码,正如您所看到的,我遵循了说明.
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'example@example.com',
),
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'pick up a password here',
),
),
);然而,当我访问index.php?r=gii时,会发现以下错误:
Error 404 Unable to resolve the request "gii".FYI使用1.1.12版本,这是最新的稳定版本。
更新
我删除了一切,重新开始,现在正在工作。一定是在路上做了什么傻事
发布于 2012-09-19 20:22:22
您已经在第21行拥有配置数组的'modules'键了,这里是http://pastebin.com/x3zWWLtm。删除您手动添加的键'modules',并在第21行中取消注释'gii':
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
// ...
'modules'=>array(
// uncomment the following to enable the Gii tool
/*
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
*/
),
// ...
);我刚刚下载了最新的yii并创建了一个web应用程序:
f0t0n@lotus:~/public_html/localhost/yii$ php framework/yiic webapp ../yiiapp然后删除gii模块的行(包括配置中的),就像我提到的那样,它的工作非常完美:http://localhost/yiiapp/index.php?r=gii
发布于 2013-07-31 16:51:07
我也遇到了同样的问题,我只是在config/main.php中临时评论了数组的内容,即rules键的值:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(/*
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>'=>'<controller>/index',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>'*/
),
'showScriptName'=>false,
),然后我访问了gii,生成了控制器和视图,最后取消了这些行的注释。
发布于 2014-06-09 00:30:21
好吧,你有没有试过另一个uri,比如:localhost/site/error
如果获得404,那么这是一个.htaccess问题,请尝试将以下代码保存在根目录下的.htaccess文件中:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule ^.*$ /index.php [L]https://stackoverflow.com/questions/12501858
复制相似问题