我使用CI v2.0.3,examplep windows 1.7.0,并将CI文件夹重命名为"Hello"
我在application/controller上创建了一个Blog.php。
Blog.php的内容是:
<?php
if(!defined('BASEPATH')) exit('No Direct Script Access Allowed');
class Blog extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
echo "Haloo.. CI pertama";
}
}
我想访问localhost:8080/hello/index.php/blog
或localhost:8080/hello/index.php/Blog
,但它们仍然显示404 not found
这就是我所期望的:"Haloo…CI pertama"。
如果你的CI文件夹名为"Hello",那么你可以这样访问它:
http://localhost:8080/Hello/index.php/blog
见鬼!文件夹名称区分大小写,因此/hello/index.php/blog
将无法在中工作
如果您没有为Apache启用"重写"模块,则您输入的URL不正确。对于考虑文件夹名称的设置,也可以尝试:
http://localhost:8080/Hello/index.php?/blog
编辑:添加的文件夹名称
您需要在索引操作中呈现视图。
您的视图位于应用程序/视图中。因此,您必须创建一个名为index.php
的文件,将Hello World
放入其中。然后你将把这个添加到你的功能中:
$this->load->view('index');
希望这能有所帮助。