【问题标题】:CodeIgniter: 404 Page Not Found ( In Hosting Server )CodeIgniter:404 页面未找到(在托管服务器中)
【发布时间】:2015-07-21 20:07:49
【问题描述】:

注意:当我在 Localhost 中尝试时一切顺利。

所以当我想在我的登录表单中调用我的 do_login 控制器时遇到了问题。

这是我的控制器:

<?php 

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Do_login extends CI_Controller {

    public function __construct()
    {
            parent::__construct();
            $this->load->model('login_model', '', TRUE);
    }

    public function index()
    {
            $this->load->library('form_validation');

            $this->form_validation->set_rules('email', 'email', 'trim|required');
            $this->form_validation->set_rules('password', 'password', 'trim|required|callback_check_database');


            if($this->form_validation->run() == FALSE)
            {
                    $this->load->view('admin/login_view'); 
            }
            else
            {
                    redirect('home', 'refresh');
            }       
    }

    public function check_database($password)
    {
            $email = $this->input->post('email', TRUE);

            $result = $this->login_model->check_login($email, $password);

            if($result)
            {
                    $sess_array = array();
                    foreach($result as $row)
                    {
                            $sess_array = array(
                                'user_id' => $row->user_id,
                                'email' => $row->email
                            );
                            $this->session->set_userdata('logged_in', $sess_array);
                    }
                    return TRUE;
            }
            else 
            {
                    $this->form_validation->set_message('check_database', 'Email / Password salah');
                    return FALSE;
            }
    }

}

?>

这是我的看法:

<?php
      $attributes = array('class' => 'form-signin', 'id' => 'myform');
      echo form_open('do_login', $attributes);
 ?>

当我在 Localhost 中尝试时,一切都很顺利。 但是当我在我的网络服务器上尝试时,每次我提交登录表单时,我都会直接进入 404。

感谢您的帮助:)

【问题讨论】:

  • 确保您的文件名以大写字母开头。所以你的 Do_login 文件,应该是 Do_login.php(大写 D)
  • 您在 config.php 的基本网址是什么?你重定向了哪个404? CI 或服务器默认值。
  • @Craig : 当然我所有的控制器文件都以大写字母开头
  • $config['base_url'] 检查 config.php 文件中的内容
  • yaa url 已打开,这不是 cofig.php 文件的包含

标签: php codeigniter url


【解决方案1】:

检查您的文件名因为在我身上发生了不同的案例文件名在本地主机上工作但不在服务器上工作。 所以检查一次。

【讨论】:

    猜你喜欢
    • 2016-05-19
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 1970-01-01
    • 2014-01-22
    相关资源
    最近更新 更多