Codeigniter 控制器方法 404 错误
Codeigniter controller method 404 error
我今天使用 link 从 github 克隆了一份 Codeigniter:https://github.com/bcit-ci/CodeIgniter.git. I am currently running MAMP setup so that http://localhost:8888 points to my htdocs folder. My root folder is called 'time'. When I go to http://localhost:8888/time/index.php,我确实看到了 Codeigniter 欢迎页面。此外,我可以访问 http://localhost:8888/time/ 并看到相同的欢迎页面,即使我在根目录中没有 .htaccess 文件。
问题来了。我将以下功能添加到 Welcome.php 控制器 class:
public function test()
{
echo 'Test';
}
当我访问 http://localhost:8888/time/index.php/test 时,这应该会显示一个显示 'test' 的页面。但是,我收到 404 页面未找到错误。有人对理解和解决这个问题有什么建议吗?
因为localhost/index.php/test
没有引用欢迎控制器中的方法测试。您必须前往 localhost/index.php/welcome/test
或使用路线。
你这样做意味着有一个名为 Test.php
的控制器,它正在尝试转到该控制器的 index()
功能。
我今天使用 link 从 github 克隆了一份 Codeigniter:https://github.com/bcit-ci/CodeIgniter.git. I am currently running MAMP setup so that http://localhost:8888 points to my htdocs folder. My root folder is called 'time'. When I go to http://localhost:8888/time/index.php,我确实看到了 Codeigniter 欢迎页面。此外,我可以访问 http://localhost:8888/time/ 并看到相同的欢迎页面,即使我在根目录中没有 .htaccess 文件。
问题来了。我将以下功能添加到 Welcome.php 控制器 class:
public function test()
{
echo 'Test';
}
当我访问 http://localhost:8888/time/index.php/test 时,这应该会显示一个显示 'test' 的页面。但是,我收到 404 页面未找到错误。有人对理解和解决这个问题有什么建议吗?
因为localhost/index.php/test
没有引用欢迎控制器中的方法测试。您必须前往 localhost/index.php/welcome/test
或使用路线。
你这样做意味着有一个名为 Test.php
的控制器,它正在尝试转到该控制器的 index()
功能。