用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2464|回复: 4
收起左侧

请教

[复制链接]
发表于 2012-3-1 11:53:27 | 显示全部楼层 |阅读模式
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Index extends CI_Controller {

        function __construct()
                {
                parent::__construct();
        }
        /**
         * Index Page for this controller.
         *
         * Maps to the following URL
         *                 http://example.com/index.php/welcome
         *        - or -  
         *                 http://example.com/index.php/welcome/index
         *        - or -
         * Since this controller is set as the default controller in
         * config/routes.php, it's displayed at http://example.com/
         *
         * So any other public methods not prefixed with an underscore will
         * map to /index.php/welcome/<method_name>
         * @see http://codeigniter.com/user_guide/general/urls.html
         */
public function index()       
  {
         
                $data['aaq']="另一个";
                $data['title'] = "My Real Title";
                $data['heading'] = "My Real Heading";
        $data['welcome']="欢迎使用ci框架";
                $this->load->view('welcome_message', $data);
       
        }
public function blog()
        {
                echo '这是测试';
        }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

用http://127.0.0.1/ci/index.php 可以访问 正常
用http://127.0.0.1/ci/index.php/blog 出错404 Page Not Found The page you requested was not found.

请高人  帮我解决下  谢谢
发表于 2012-3-1 14:28:28 | 显示全部楼层
http://127.0.0.1/ci/index.php
是不是跳转到了默认的 welcome 的页面呢?

http://127.0.0.1/ci/index.php/blog
是指去application/controller/ 下找 blog.php 这个文件
你检查一下看
发表于 2012-3-1 16:26:27 | 显示全部楼层
http://127.0.0.1/ci/index.php/index/blog
发表于 2012-3-1 19:52:41 | 显示全部楼层
类名最好和文件名保持一致
发表于 2012-3-1 20:01:54 | 显示全部楼层
你去自习看看 CI 的 url  2楼讲的是对的
只是你这个命名等尽量按照规范
而且一般少用 Index做类名的
你这个就可以直接改成用 Blog 做类名
blog方法的  echo 放到index 最后面就可以了

本版积分规则