404页面未找到codeigniter网址 [英] 404 Page Not Found codeigniter url

查看:110
本文介绍了404页面未找到codeigniter网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用Codeigniter的初学者。我正在使用以下网址 http://localhost/ci/index.php/shopcart 访问控制器,但找不到错误404页面

I am a beginner using codeigniter. I am using following url "http://localhost/ci/index.php/shopcart" to access the controller and I am getting error 404 page not found

     <?php

    class Cart extends CI_Controller { // Our Cart class extends the Controller class

        function Cart()
        {
            parent::CI_Controller(); // We define the the Controller class is the parent. 

        }


    }

        function index()
        {
            $this->load->model('cart_model'); // Load our cart model for our entire class 
            $data['products'] = $this->cart_model->retrieve_products(); // Retrieve an array with all products
            $data['content'] = 'cart/products'; // Select our view file that will display our products
            $this->load->view('index', $data); // Display the page with the above defined content
        }
?>



标准代码



Model Code

<?php 

class Cart_model extends Model { // Our Cart_model class extends the Model class
// Function to retrieve an array with all product information
    function retrieve_products(){
        $query = $this->db->get('products'); // Select the table products
        return $query->result_array(); // Return the results in a array.
    }  

}



路线



Route

$route['default_controller'] = "shopcart";



自动加载



autoload

$autoload['libraries'] = array('cart' , 'database');
$autoload['helper'] = array('form');


推荐答案

codeigniter适用于base_url〜/ index.php / class_nm /功能/细分3。现在,根据您的情况更改文件名 Cart.php

codeigniter works on base_url~/index.php/class_nm/function/segment3. Now in your case change file name Cart.php.

localhost / ci / index.php / cart / index

并确保您的函数 index public ,我想它将解决您的问题:)

and make sure your function index is public, I guess it will fix your problem :)

这篇关于404页面未找到codeigniter网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆