我有一个控制器名为blog.php在我的本地主机。要访问它,我在地址栏中键入http://localhost/ci/index.php/blog。在教程中它说它会显示Hello World,但我得到的显示是一个包含blog.php代码和404 Page Not Found的页面。codeigniter控制器加载
这是代码。
*<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/blog
* - or -
* http://example.com/index.php/blog/index
* - or -
* So any other public methods not prefixed with an underscore will
* map to /index.php/blog/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
echo "Hello World";
}
}
/* End of file Blog.php */
/* Location: ./application/controllers/blog.php */*
任何人请帮助我知道是什么问题。
你可以发布config/config.php文件代码吗?也是http:// localhost/ci/working?它显示什么?而且你还没有在PHP之前使用*,对吧? – 2013-07-17 16:59:54
yes Mr.web是正确的。您的codeigniter文件在ci文件夹内?尝试在google或SO上进行搜索,并找到相同的问题,您会发现很多问题和答案。 – 2014-11-16 18:14:20