首页 文章

在用户登录上有太多的重定向

提问于
浏览
3

我在Yii中遇到太多重定向错误 .

我正在使用Yii提供的默认accessControl过滤器 .

整个应用程序在localhost上完美运行,我正在使用WAMP . 我上传到登台服务器后问题就开始了 .

我已经根据我的知识配置了.htaccess文件

Options +FollowSymLinks
IndexIgnore */*

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^.*$ /index.php [L] 
</IfModule>

如果我尝试打开不需要登录的任何操作,它会打开而不会出现故障

public function accessRules()

{

    return array(

        array('allow', // allow all users to perform 'index' and 'view' actions

            'actions' => array('index', 'locationImport', 'contact'),

            'users' => array('*'),

        ),

        array('allow', // allow authenticated user to perform 'create' and 'update' actions

            'actions' => array('LocationImport'),

            'users' => array('@'),

        ),

        array('allow', // allow admin user to perform 'admin' and 'delete' actions

            'actions' => array('admin', 'delete'),

            'users' => array('admin'),

        ),

        array('deny', // deny all users

            'users' => array('*'),

        ),

    );

}

在上述控制器中,联系人正在工作 .

我的main.php相关

'user' => array(
        // enable cookie-based authentication
        'allowAutoLogin' => true,
        'loginUrl' => array('/useraccount/login'),
        'class' => 'CPWebUser',
    ),

UserAccountController中的访问规则

public function accessRules()
{
    return array(
        array('allow', // allow all users to perform 'register' and 'login' actions
            'actions' => array('register', 'login', 'view', 'xxxx', 'xxxx',),
            'users' => array('*'),
        ),
        array('allow', // allow authenticated user to perform 'create' and 'update' actions
            'actions' => array('update', 'logout', 'home', 'changePassword'),
            'users' => array('@'),
        )
        array('deny', // deny all users
            'users' => array('*'),
        ),
    );
}

只是总结一下 . 完全适用于localhost . sitecontroller Actioncontact有效 . userAccountController中的任何操作都不起作用 . 甚至没有注册,它重定向到登录 . actionLogin没有打开 .

1 回答

  • 0

    解决了:这可能是一个愚蠢的错误 . 经过几个小时的工作,问题因为拼写错误而得到解决 .

    在linux上,main.php配置变得区分大小写,我在Windows上进行编程,而不是 .

    我的控制器是userAccount和

    'loginUrl' => array('useraccount/login'),
    

    刚改成它

    'loginUrl' => array('userAccount/login'),
    

相关问题