【问题标题】:CodeIgniter + Wamp: Unable to locate the file errorCodeIgniter + Wamp:无法定位文件错误
【发布时间】: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


【解决方案1】:

请将您的函数名称索引更改为登录。

如果你使用函数名索引,那么 url 将是 localhost/projectname/index.php/admin

如果您将函数名称更改为登录,那么这将起作用。

【讨论】:

  • 嗨,我不认为是代码的问题,因为它是在 linux 机器上运行的。我相信它的一些环境设置......但我尝试了一些设置,它仍然是一样的
  • 尝试在 route.php 中设置路由,例如 $route['admin/index'] = "admin/login";
猜你喜欢
  • 2014-07-16
  • 1970-01-01
  • 2018-03-14
  • 1970-01-01
  • 2014-06-20
  • 2011-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多