CodeIgniter: 404 Page Not Found on Live Server

前端 未结 11 1502
感动是毒
感动是毒 2020-12-03 04:46

I have been developing a small web application with CodeIgniter. After testing it out locally I went to put it on my web server to allow a couple other people test out some

相关标签:
11条回答
  • 2020-12-03 04:57

    Please check the root/application/core/ folder files whether if you have used any of MY_Loader.php, MY_Parser.php or MY_Router.php files.

    If so, please try by removing above files from the folder and check whether that make any difference. In fact, just clean that folder by just keeping the default index.html file.

    I have found these files caused the issue to route to the correct Controller's functions.

    Hope that helps!

    0 讨论(0)
  • 2020-12-03 04:58

    You are using MVC with OOPS Concept. So there are some certain rules.

    1) Your class name (ie: controller name) should be start with capital Letter.

    e.g.: your controller name is 'icecream'. that should be 'Icecream'

    In localhost it might not be compulsory, but in server it will check all these rules, else it can't detect the right class name.

    0 讨论(0)
  • 2020-12-03 05:00

    Solved the issue. Change your class name to make only the first letter capitalized. so if you got something like 'MyClass' change it to 'Myclass'. apply it to both the file name and class name.

    0 讨论(0)
  • 2020-12-03 05:05

    I have solved this problem, please just make few changes

    1- all controller class name should start with capital letter. i mean first letter of class should be capital . eg we have controler with class name Pages

    so it should be Pages not pages

    2- save the controller class Pages as Pages.php not pages.php

    so first letter must be capital

    same for model, model class first letter should be capital and also save model class as Pages_model.php not page_model.php

    hope this will solve ur problem

    0 讨论(0)
  • 2020-12-03 05:06

    Changing the first letter to uppercase on the file's name and class name works.

    file: controllers/Login.php

    class: class Login extends CI_Controller { ... }

    The file name, as the class name, should starts with capital letter. This rule applys to models too.

    https://www.codeigniter.com/user_guide/general/models.html

    0 讨论(0)
  • 2020-12-03 05:07

    I am doing it on local and production server this way:


    Routes:

    $route['default_controller']   = 'Home_controller';
    

    Files' names:

    • in controllers folder: Home_controller.php
    • in models folder: Home_model.php
    • in views folder: Home.php

    Home_controller.php:

           class Home_controller extends CI_Controller {
    
               public function index(){
    
                  //loading Home_model
                  $this->load->model('Home_model');
    
                  //get data from DB
                  $data['db_data']  = $this->Home_model->getData();
    
                  //pass $data to Home.html
                  $this->load->view('Home', $data);
               }
           }
    

    Home_model.php:

           class Home_model extends CI_Model {
           ...
           }
    

    There should be no more problems with cases anymore :)

    0 讨论(0)
提交回复
热议问题