Yii无法启动gii(Yii can't start gii)

我正在开发PHP Yii Framework的网站,现在我正在开发堆栈,我需要启动gii,但是我不能这样做。 当我输入www.example.com/index.php/gii或www.example.com/gii时,它给了我这个错误:

/gii/default/login // <- website redirects to here This webpage has a redirect loop The webpage at http://www.example.com/gii/default/login has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

我不认为这个错误是因为修改了htaccess和主配置,但无论如何这里是main.php配置文件:

'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( 'site/page/<view:\w+>'=>'site/page', '<controller:\w+>/<cact:\w+>/<action:\w+>'=>'<controller>/<cact>', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),

和.htaccess:

Options +FollowSymLinks IndexIgnore */* RewriteEngine on #non-www to www RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] # 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]

所以你能帮助我吗?

I am developing website with PHP Yii Framework and I am now stack, I need to start gii, but I can't do this. when i type www.example.com/index.php/gii or www.example.com/gii it gives me this error :

/gii/default/login // <- website redirects to here This webpage has a redirect loop The webpage at http://www.example.com/gii/default/login has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

I don't think that the error is because of modified htaccess and main configuration, but anyway here is main.php configuration file:

'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( 'site/page/<view:\w+>'=>'site/page', '<controller:\w+>/<cact:\w+>/<action:\w+>'=>'<controller>/<cact>', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),

and .htaccess :

Options +FollowSymLinks IndexIgnore */* RewriteEngine on #non-www to www RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] # 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]

So can you help me, please?

最满意答案

检查配置文件中的gii模块是否存在,并取消注释。 如果gii不在那里,你应该在模块数组中添加它。

'modules'=>array( 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>***choose a password*** ), ),

更多关于gii的信息在这里

Check if the gii module in your configuration file is there and it is uncommented. If gii is not in there you should add it within the module array.

'modules'=>array( 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>***choose a password*** ), ),

More info for gii here

更多推荐