I've uploaded my Yii application to an Ubuntu 12.04 server running PHP5 and Apache2.x. The .htaccess file contains:
RewriteEngine on
RewriteBase /
The UserController.php in /protected/controllers contains:
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));
}
When I login to the site, I receive an HTTP404 message. The apache2 error.log states
file does not exist /var/www/users
How can I rectify this 404 error?
UPDATE:
It doesn't appear that returnURL is valued. How do I setup returnUrl so that the user is redirected back to the previous page?
UPDATE2: Here is a snippet from 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>',
),
Here's the contents of the main .htacess file:
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
UPDATE: It looks like the root cause might be relative to the UserIdentity class being used to authenticate. Here's a snippet of the users model:
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;
}
}
Would it be advisable to use CdbHttpSession insead of UserIdentity to accomplish login?