【发布时间】:2016-10-06 11:19:47
【问题描述】:
我在使用 codeigniter 3 时遇到问题,我使用 netbeans 作为我的 IDE 和 wampserver。 我能够成功浏览到“localhost/ci_test/”(ci_test 是项目/网站的名称),它为我提供了默认的welcome.php 控制器, 但是我在名为“Test.php”的 CI 控制器文件夹中尝试了第二个控制器,其内容如下:
<?php
class Test extends CI_Controller {
public function index() {
echo "This is default function.";
}
public function hello() {
echo "This is hello function.";
}
}
?>
然后当我尝试浏览到该控制器时:使用以下网址: http://localhost/ci_test/index.php/test 它为我服务了我的welcome.php(这不是我想要的),
然后我尝试了这个网址: http://localhost/ci_test/test.php
我得到了回应:
Not Found
The requested URL /ci_test/test.php was not found on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80
我不明白我在这里错过了什么......
注意:我没有更改 codeigniter 提供的 .htacess 文件,而是保持原样(可能是那里的问题)。
我在 CI 中只更改了以下内容:
应用程序/config/config.php:
$config['base_url'] = 'http://localhost/ci_test/';
$config['index_page'] = ''
$config['uri_protocol'] = 'PATH_INFO';
我希望有人可以在这里提供帮助:)
编辑: 我已经阅读了前 4 个答案,但它仍然不起作用
编辑2: 所以在我决定放弃之后,我注意到我的 apache 服务器没有打开“mod_rewrite”,所以我打开了它 再次尝试了同一个项目,但它仍然没有工作,然后我决定从头开始创建一个新项目,并使用 CI,我添加了新的控制器,现在一切正常。这是大声笑... 非常感谢所有试图帮助我的人:)
【问题讨论】:
-
想想吧。您的系统总是从 'localhost/ci_test/' 开始,如果它没有运行,那么各种事情都无法设置。因此,在调试时,您总是从起始页运行到要调试的位置。如果你在感兴趣的脚本上设置断点,当你通过网站的正常流程到达那里时,断点就会触发。
标签: php codeigniter netbeans wamp