在我正确配置的codeigniter中,主页没有响应,我尝试调试但找不到错误
请看下面的代码
config / routes.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = 'home';
//$route['404_override'] = '';
//this for the admininstration console
$route['admin'] = 'admin/dashboard';
$route['admin/media/(:any)']= 'admin/media/$1';
controllers / home.php
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library('form_validation');
$this->load->model('Category_model');
$this->load->model('Product_model');
$this->load->model('Option_model');
$this->load->model('ratenreview_model');
//load Dentkart library
$this->load->library('Banners');
$this->load->library('Menus');
$this->load->model(array('location_model'));
$this->load->model('Customer_model');
$this->load->model('Testimonial_model');
$this->load->library('dentkart');
$this->load->helper(array('formatting_helper'));
$this->customer = $this->dentkart->customer();
}
private function index() {
$this->data['page'] = "Home";
$this->ratenreview_model->ecash_event_date('dob');
$this->ratenreview_model->ecash_event_date('clinic_anniversary');
$this->ratenreview_model->ecash_event_date('marrg_aniversary');
$arrCatHome =array(440,468,472,568);
for($i=0;$i<count($arrCatHome);$i++){
$data['arrCategories'][] = $this->Category_model->get_category($arrCatHome[$i]);
$data['products'][$arrCatHome[$i]] = $this->Product_model->get_homepage_category_products($arrCatHome[$i]);
foreach ($data['products'][$arrCatHome[$i]] as &$p){
$p->images = (array)json_decode($p->images);
$p->options = $this->Option_model->get_product_options($p->id);
}
}
$data['arrShopByBrand'] = $this->Product_model->get_shop_brands();
//$data['arrHomeProducts'] = $this->Product_model->getHomeProducts();
//get all booktype
//$data['arrBooktype'] = $this->Product_model->get_book_types();
$data['arrTestimonial'] = $this->Testimonial_model->getTestimonialList();
$this->load->view('vwHome',$data);
}
}
.htaccess
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L]
,并且还尝试更改溃败中的默认控制器,并得到404错误 请帮我解决问题
答案 0 :(得分:0)
private function index() {
应该是public function index() {
路由器无法查看/显示私有方法。控制器中的私有方法应该很少使用,并且通常仅用于较小的“ helper”函数,用于常用的类。
答案 1 :(得分:0)
只需将private function index()
控制器中的Home
更改为公共功能
答案 2 :(得分:0)
更改route.php
$route['default_controller'] = 'Home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;