【问题标题】:Codeigniter controller method 404 errorCodeigniter 控制器方法 404 错误
【发布时间】:2019-01-05 01:38:18
【问题描述】:

我今天使用此链接从 github 克隆了 Codeigniter 的副本:https://github.com/bcit-ci/CodeIgniter.git。我目前正在运行 MAMP 设置,以便 http://localhost:8888 指向我的 htdocs 文件夹。我的根文件夹称为“时间”。当我转到http://localhost:8888/time/index.php 时,我确实看到了 Codeigniter 欢迎页面。另外,即使根目录中没有 .htaccess 文件,我也可以访问 http://localhost:8888/time/ 并看到相同的欢迎页面。

这就是问题所在。我在 Welcome.php 控制器类中添加了以下函数:

public function test()
{
    echo 'Test';
}

当我访问http://localhost:8888/time/index.php/test 时,这应该会显示一个显示“测试”的页面。但是,我收到 404 page not found 错误。有人对理解和解决这个问题有什么建议吗?

【问题讨论】:

    标签: php codeigniter url-routing


    【解决方案1】:

    因为localhost/index.php/test 没有引用欢迎控制器中的方法测试。您必须前往localhost/index.php/welcome/test 或使用路线。

    你这样做的方式意味着有一个名为 Test.php 的控制器,它正试图转到该控制器的 index() 函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-10
      • 2014-06-03
      • 2019-10-06
      • 2016-02-22
      • 2013-08-14
      • 2013-12-11
      • 2013-03-14
      • 2020-11-28
      相关资源
      最近更新 更多