错误:找不到404页面,代码点火器

时间:2015-01-31 07:15:41

标签: php codeigniter http-status-code-404

Controller.php这样

<?php

    define('_root',$_SERVER['DOCUMENT_ROOT']);
    include(_root.'/innoshop/application/models/model.php');

     // include_once 'model.php';

    class Controller {
     public $model;

     public function __construct()  
        {  
            $this->model = new Model();

        }

如果我把localhost:8888 / projectname,我得到这样的错误

 404 Page Not Found

The page you requested was not found.
任何人帮助我

1 个答案:

答案 0 :(得分:1)

正如那些人说你应该阅读文档,因为这是非常错误的。要解决这个问题..

class Controller extends CI_Controller{//better to give your controller a more meaningful name

       public function __construct(){
           parent::__construct();
           //use the CI loader - the model will then be available like this $this->model->some_function();
           $this->load->model('model');//better to give your model a more meaningful name as well 
       }

       //the index method allows you to use just the controller name in your URI eg localhost:8888/projectname/index.php/controller 
       public function index(){
           echo 'something to see';
       }

        //an alternative controller method get it like localhost:8888/projectname/index.php/controller/your_method_name
        public function your_method_name(){
           echo 'something to see in your method';
        }

} 

如果你想在URI搜索中删除index.php中与CodeIgniter中的.htaccess相关的问题

如果您希望能够使用这样的localhost:8888/projectname这样的uri,那么您需要在config / routes.php中添加一个定义默认控制器的路由,如$route['default']='controller';

相关问题