Php 使用Codeigneter框架进行导航

Php 使用Codeigneter框架进行导航,php,Php,基本上我有一个名为site.php的控制器,它有几个视图:header.php、nav.php、content.php、footer.php等等。问题是如何运行content_about.php? 我正在尝试此url:site/about,但我在浏览器上出错! 代码是: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class site extends CI_Controller {

基本上我有一个名为site.php的控制器,它有几个视图:header.php、nav.php、content.php、footer.php等等。问题是如何运行content_about.php? 我正在尝试此url:site/about,但我在浏览器上出错! 代码是:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class site extends CI_Controller {

    public function index()
    {
        $this->home();
    }
    public function home()
    {
        $this->load->view("site_header");
        $this->load->view("site_nav");
        $this->load->view("content_home");
        $this->load->view("site_footer");
    }
    public function about()
    {
        $this->load->view("site_header");
        $this->load->view("site_nav");
        $this->load->view("content_about");
        $this->load->view("site_footer");
    }
}
试试这个

public function about()
{
    $data=array();
    $data['main']='content_about'; //only the content part without header,nav and footer
    $this->load->view('template',$data);
}
在视图make template.php中,将以下行

<?=$this->load->view('site_header.php');?>
<?=$this->load->view('site_nav.php');?>
<?=$this->load->view($main);?>
<?=$this->load->view('site_footer');?>


如果您遇到任何问题,请告诉我。

什么错误?代码错误为“在此服务器上找不到请求的URL/basicsite/about”。您上面提供的URL指的是控制器
basicsite
。请确保您的文件名也是
basicsite.php
,而不是
site.php
,谢谢,但是,它不再工作了。我缺少什么?htacces文件中包含“拒绝来自所有人”。这会导致该问题吗?以下链接可能有助于我回答您的问题。请在使用后让我知道该sattus。