dongshuo6503 2013-04-15 11:22
浏览 82
已采纳

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

I am getting errors for too many redirects in Yii.

I am using the default accessControl filter provided by Yii.

The whole application works perfectly on localhost, where i am using WAMP. The problem started occuring after i uploaded to a staging server.

I have configured the .htaccess file to the best of my knowledge

Options +FollowSymLinks
IndexIgnore */*

<IfModule mod_rewrite.c>
RewriteEngine on

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

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

If i try to open any action where login is not required it opens without a glitch

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('*'),

        ),

    );

}

In the above controller the contact is working.

my main.php relevant

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

Access rules in 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('*'),
        ),
    );
}

Just to sum up. completely works on localhost. sitecontroller Actioncontact works. No action in userAccountController works. Not even register, it redirects to login. actionLogin doesnt open.

  • 写回答

1条回答 默认 最新

  • dragon201401 2013-04-15 20:11
    关注

    Solved: It was as silly a mistake as could be. After hours of working, problem got solved because of a typo.

    On linux the main.php config becomes case sensitive, i was programming on windows where it was not.

    my controller was userAccount and the

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

    just changed it to

    'loginUrl' => array('userAccount/login'),
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?