【发布时间】:2015-06-19 15:28:03
【问题描述】:
我刚刚安装了全新安装的 Wamp 服务器并将一个工作的 CodeIgniter 项目(不是我做的)复制到其中。我已经更改了 config.php(base_url) 和 database.php(mysql credentials) 中的设置,并确定数据库连接正常。
我可以看到登录页面,但是当我登录时,它返回“无法找到文件错误”,我相信它需要在 Wamp 服务器上进行一些设置。根 CI 文件夹中没有 .htaccess 文件,应该有吗?有什么建议可能出了什么问题?
在控制器文件夹中有一个 admin.php 文件
<?php
class Admin extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->lang->load($this->config->item('admin_language'), $this->config->item('admin_language'));
}
private $rules = array(
array(
'field' => 'username',
'label' => 'lang:username',
'rules' => 'trim|required',
),
array(
'field' => 'password',
'label' => 'lang:password',
'rules' => 'trim|required|min_length[8]',
)
);
function index()
{
$this->load->library('form_validation');
$redirect_to = $this->config->item('base_url') . 'index.php/admin/products/';
if ($this->auth->logged_in() == FALSE)
{
$data['error'] = FALSE;
$this->load->library('form_validation');
$this->form_validation->set_rules($this->rules);
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
//echo "1";die;
if ($this->form_validation->run() == FALSE)
{
//echo "if";die;
$this->load->view('admin/login', $data);
}
else
{
//echo "el";die;
$this->auth->login($this->input->post('username'), $this->input->post('password'), $redirect_to, 'index.php/admin/login');
}
}
else
{
//echo "asdadad";die;
redirect($redirect_to);
}
}
function logout()
{
$this->auth->logout($this->config->item('base_url') . 'index.php/admin');
}
}
?>
【问题讨论】:
-
查看apache的错误日志
-
我检查了 apache_error.log 文件,它只显示启动和关闭消息
-
你可以发布调用视图的行吗?
-
您在视图文件夹中。 URL 需要 controllers/login.php 文件。
-
在controllers文件夹中,只有一个admin.php和index.html
标签: php apache .htaccess codeigniter wamp