Yii can't start gii

I am developing a website with the PHP Yii Framework and now I am putting the stack, I need to run gii, but I cannot do this. when I print 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 do not think the error is caused by the htaccess change and the main configuration, but in any case, here is the 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?

+4
source share
5 answers

Check if the gii module is in your configuration file and it is uncommented. If gii is missing, you should add it to the array of modules.

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

More info for gii here

+4
source

To use this path: index.php?r=gii/default/login , you must disable the URL manager in /protected/config/main.php

+6
source

Also check urlManager rules . This was a problem for me:

 'components' => array( 'urlManager' => array( 'urlFormat' => 'path', 'showScriptName' => false, 'rules' => array( // ... // will handle `gii/default/login` uri and makes infinite redirection loop circle '<controller:\w+>/<action:\w+>/<sub_action:\w+>'=>'<controller>/<action>', // ... ), ), ), 
+5
source

As FelikZ mentioned , it could be because you created the third parameter in the rule that uses \w+ instead of the standard \d+ and therefore will match "gii" as the controller, "default" as the action and "login" as identifier (or sub-action or something else mentioned).

My rules were as follows:

 '<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 

The fix is ​​to add the following as the very first rule so that gii gets to the right place:

 'gii/<controller:\w+>/<action:[\w-]+>' => 'gii/<controller>/<action>', 

What should make your whole urlManager configurator look something like this:

 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( 'gii/<controller:\w+>/<action:[\w-]+>' => 'gii/<controller>/<action>', '<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ), 
+4
source

This problem occurs due to two OP sessions, for example, the cookie PHPSESSID there are two domains of the domain .site.ru and admin.site.ru two different sessions. Delete PHPSESSID cookies and login to gii

+1
source

Source: https://habr.com/ru/post/1401433/


All Articles