Yii GII404错误。无法使用Gii
在本教程之后,它提到了向/blog/protected/config/main.php添加一些代码Yii GII404错误。无法使用Gii,yii,installation,http-status-code-404,gii,Yii,Installation,Http Status Code 404,Gii,在本教程之后,它提到了向/blog/protected/config/main.php添加一些代码 return array( ...... 'import'=>array( 'application.models.*', 'application.components.*', ), 'modules'=>array( 'gii'=>array( 'class'=>'
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".
仅供参考-我使用的是1.1.12版,这是最新的稳定版本
更新
我删除了所有内容并重新开始,现在正在工作。一定是在途中做了些傻事这里第21行已经有了配置数组的
'modules'
键。删除手动添加的键'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'),
),
*/
),
// ...
);
然后,如我所述,取消对配置中包含的
gii
模块行的注释,它工作得非常完美:您已经在第21行有了配置数组的'modules'
键。删除手动添加的键'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'),
),
*/
),
// ...
);
然后,如我所提到的,取消了config中包含的
gii
模块的行注释,它工作得很好:我也遇到了同样的问题,我只是在config/main.php中临时注释了数组的内容,即规则
键的值:
'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,
),
'urlManager'=>数组(
“urlFormat'=>“路径”,
'规则'=>数组(/*
“/”=>“/视图”,
''=>''/index',
'//'=>'/',
'/'=>'/'*/
),
'showScriptName'=>false,
),
然后我访问了
gii
,生成了我的控制器和视图,最后取消了这些行的注释。我也遇到了同样的问题,我只是在config/main.php中临时注释了数组的内容,即规则
键的值:
'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,
),
'urlManager'=>数组(
“urlFormat'=>“路径”,
'规则'=>数组(/*
“/”=>“/视图”,
''=>''/index',
'//'=>'/',
'/'=>'/'*/
),
'showScriptName'=>false,
),
然后我访问了
gii
,生成了我的控制器和视图,最后取消了这些行的注释。那么,您是否尝试了另一个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]
那么,您是否尝试了另一个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]
需要你的完整配置。还有路由规则。这是默认的路由规则。这是我的第一个yii应用程序,在新安装之后,我将继续学习教程。您的应用程序文件夹中是否有.htaccess?需要完整配置。还有路由规则。这是默认的路由规则。这是我的第一个yii应用程序,在新安装之后,我将继续学习教程。你的应用程序文件夹中有.htaccess吗?我已经试过了。。。它不起作用。这就是为什么我再次注释它,并尝试在结尾添加它。。。just-in-case.config.php应该只有一个模块数组,否则它将被最后一个数组覆盖。同样的问题也发生在我身上,通过将两个模块阵列组合成一个各自的阵列来解决它。我已经尝试过了。。。它不起作用。这就是为什么我再次注释它,并尝试在结尾添加它。。。just-in-case.config.php应该只有一个模块数组,否则它将被最后一个数组覆盖。同样的问题也发生在我身上,通过将两个模块阵列组合成一个具有各自阵列的阵列来解决它。