Php 404页未找到codeigniter url
我是一个使用codeigniter的初学者。我正在使用以下url“”访问控制器,并且我发现错误404页面未找到 控制器代码 自动加载Php 404页未找到codeigniter url,php,codeigniter,http-status-code-404,Php,Codeigniter,Http Status Code 404,我是一个使用codeigniter的初学者。我正在使用以下url“”访问控制器,并且我发现错误404页面未找到 控制器代码 自动加载 codeigniter在base_url~/index.php/class_nm/function/segment3上工作。现在,在您的情况下,更改文件名Cart.php 确保你的函数索引是公共的,我想它会解决你的问题:)你得到404页未找到错误,因为控制器“shopcart”没有定义。相反,您定义了一个控制器“购物车”。因此,您应该尝试localhost/ci
codeigniter在base_url~/index.php/class_nm/function/segment3上工作。现在,在您的情况下,更改文件名
Cart.php
确保你的函数
索引是公共的
,我想它会解决你的问题:)你得到404页未找到错误,因为控制器“shopcart”没有定义。相反,您定义了一个控制器“购物车”。因此,您应该尝试localhost/ci/index.php/cart
。尝试添加url帮助程序。那对我有用 是问题所在,因为它正在搜索index.php文件夹。Try您的类名看起来像购物车,因此您可以尝试或显示“此服务器上未找到请求的URL/ci/shopcart”。还显示404未找到页面。我使用的是codeigniter 3这不是CI3的好代码。这是CI v localhost/CI/index.php/cart/index中使用的代码,也显示404页面未找到我的索引函数在默认情况下是公共的,如随附的代码中所述。请注意,我的控制器文件是shopcart.php将其更改为Cart.php
<?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
}
?>
<?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['default_controller'] = "shopcart";
$autoload['libraries'] = array('cart' , 'database');
$autoload['helper'] = array('form');