Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 易能';不要启动gii_Php_Redirect_Frameworks_Yii_Gii - Fatal编程技术网

Php 易能';不要启动gii

Php 易能';不要启动gii,php,redirect,frameworks,yii,gii,Php,Redirect,Frameworks,Yii,Gii,我正在用PHPYII框架开发网站,我现在是stack,我需要启动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/

我正在用PHPYII框架开发网站,我现在是stack,我需要启动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.

那么,您能帮助我吗?

检查您的配置文件中的gii模块是否在那里并且没有注释。 如果gii不在其中,则应将其添加到模块阵列中

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

gii的更多信息要使用此路径:
index.php?r=gii/default/login
,必须在
/protected/config/main.php
中关闭url管理器,同时检查
urlManager
规则。这就是我的问题:

'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>',
            // ...
        ),
     ),
 ),
“组件”=>阵列(
“urlManager”=>数组(
“urlFormat”=>“路径”,
'showScriptName'=>false,
'规则'=>数组(
// ...
//将处理'gii/default/login'uri并使无限重定向循环循环
'//'=>'/',
// ...
),
),
),

出现此问题的原因是OP的两个会话,例如cookie PHPSESSID有两个域domain.site.ru和admin.site.ru两个不同的会话。删除PHPSESSID cookies并登录到gii

类似,这可能是因为您在使用
\w+
而不是默认
\d+
的规则中创建了第三个参数,因此将匹配“gii”作为控制器,“default”作为操作,“login”作为ID(或子操作,或提及的任何内容)

我的规则如下所示:

'<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'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>',
    ),
),

它是在main.php中设置的allready,我可以使用Gii,直到我将默认URL更改为用户友好URL。在我发布的第二段代码中,它说明了如果您使用用户友好URL,您必须执行的操作。非常感谢,一切都按需运行!再次谢谢你!
'<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'gii/<controller:\w+>/<action:[\w-]+>' => 'gii/<controller>/<action>',
'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>',
    ),
),