1
<?php
class Page extends CI_Controller{

    function index(){
        $this->view('home');
    }

    public function view($page = 'home')
    {

        if ( ! file_exists('application/views/pages/'.$page.'.php'))
        {
            // Whoops, we don't have a page for that!
            show_404();
        }

        $data['title'] = ucfirst($page); // Capitalize the first letter

        $this->load->view('templates/header', $data);
        $this->load->view('pages/'.$page, $data);
        $this->load->view('templates/footer', $data);

    }

我想查看带有http://www.mydomain.com/page/abouthttp://www.mydomain.com/page/services等链接的页面,而不是http://www.mydomain.com/ 格式page/view/abouthttp://www.mydomain.com/page/view/services

我该怎么做?

4

2 回答 2

5

您可以在config/routes.php其中添加路线:

$route['page/(:any)'] = "/page/view/$1";
于 2013-01-24T19:26:56.337 回答
3

在 /config/route.php 中为您的特定静态页面设置路由。

$route['contact']   = 'site/page/contact';
于 2013-01-24T19:26:39.873 回答