我已将我的 Yii 应用程序上传到运行 PHP5 和 Apache2.x 的 Ubuntu 12.04 服务器。.htaccess 文件包含:
RewriteEngine on
RewriteBase /
/protected/controllers 中的 UserController.php 包含:
 public function actionLogin()
{
    $model= new Users();
    // if it is ajax validation request
    if(isset($_POST['ajax']))
    {
        echo CActiveForm::validate($model);
        Yii::app()->end();
    }
//                print_r($_POST['Users']);
    // collect user input data
    if(isset($_POST['Users']))
    {
        $model->attributes=$_POST['Users'];
        // validate user input and redirect to the previous page if valid
        if($model->login())
            $this->redirect(Yii::app()->user->returnUrl);
    }
    // display the login form
    $this->render('login',array('model'=>$model));
}
当我登录该站点时,我收到一条 HTTP404 消息。apache2 error.log 状态
file does not exist /var/www/users
如何纠正这个 404 错误?
更新:
returnURL 似乎没有被重视。如何设置 returnUrl 以便将用户重定向回上一页?
UPDATE2:这是来自 config/main.php 的片段:
'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName'=>false,
        'rules'=>array(
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),
这是主 .htacess 文件的内容:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin/(.*)\?*$ admin.php/$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
php_value upload_max_filesize 20M
php_value post_max_size 21M  
更新:看起来根本原因可能与用于身份验证的 UserIdentity 类有关。这是用户模型的片段:
public function login()
{
        if($this->_identity===null)
        {
                $this->_identity=new UserIdentity($this->username,md5($this->password));
                $this->_identity->authenticate();
        }
        if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
        {
                $duration=$this->rememberMe ? 3600*24*30 : 60*20; // 30 days
                Yii::app()->user->login($this->_identity,$duration);
                return true;
        }
        else{
                $this->addError('password','Incorrect username or password.');
                return false;
        }
}
是否建议使用 CdbHttpSession 代替 UserIdentity 来完成登录?