繁体   English   中英

主页未在Codeigniter中打开

[英]home page is not opening in codeigniter

我正确配置的codeigniter中的主页未响应,我尝试调试但找不到错误

请看下面的代码

配置/ 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';

控制器/ 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]

并且还尝试更改溃败中的defualt控制器,它得到404错误,请帮助我如何解决问题

private function index() {应该是public function index() {

路由器看不到/显示私有方法。 控制器中的私有方法应该很少使用,并且通常仅用于较小的“ helper”函数,用于常用的类。

只需将Home控制器中的private function index()更改为公共函数

更改route.php

 $route['default_controller'] = 'Home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM