php – Codeigniter设置主页(默认控制器)

我正在尝试在我的codeigniter应用程序中实现页面模板,模板工作正常,例如,我有一个博客页面,我试图指定为我的主页,具有不同的视图和分页等等.当我写www.mywebsite.com/blog时,它会在主页模板中打开,或者假设我有一个页面www.mywebsite.com/about,它也会在页面模板中打开.但是当我尝试通过www.mywebsite.com访问我的网站时,我有一个404错误页面.如何将我的博客页面指定为主页?

页面控制器:

class Page extends Frontend_Controller {

public function __construct(){
    parent::__construct();
    $this->load->model('page_m');
}

public function index() {

// Fetch the page template
$this->data['page'] = $this->page_m->get_by(array('slug' => (string) $this->uri->segment(1)),TRUE);
count($this->data['page']) || show_404(current_url());

add_Meta_title($this->data['page']->title);
add_Meta_keyword($this->data['page']->keywords);
add_Meta_description($this->data['page']->description);

// Fetch the page data
$method = '_' . $this->data['page']->template;
if (method_exists($this,$method)) {
        $this->$method();
}
else {
log_message('error','Could not load template ' . $method .' in file ' . __FILE__ . ' at line ' . __LINE__);
}

// Load the view
$this->data['subview'] = $this->data['page']->template;
$this->load->view('_main_layout',$this->data);
}

private function _page(){ // methods }
private function _homepage(){ // methods }
}

在我的路线中,我已将认控制器设置为页面控制器

$route['default_controller'] = "page";
问题是,当您访问www.mywebsite.com时,没有URI段.您可以尝试将认值设置为:
$this->uri->segment(1,'blog')

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...