首页 文章

除默认控制器外,为什么会出现404 Page Not Found错误

提问于
浏览
0

我正在使用OS Ubuntu . 我正在运行代码时在codeigniter上创建应用程序并面临问题 . 只有默认控制器正在工作,其他则不起作用,应用程序通过错误:

404找不到页面找不到您请求的页面 .

代码:控制器名称:测试

defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends CI_Controller {

    public function index()
    {
        echo "Hi this is Test Controller";
    }
}

1 回答

  • 1

    CI可能有很多原因可以显示 404 Page Not Found .

    例如

    • 如果控制器文件夹中不存在该文件 .

    • 如果在这种情况下使用CI-3文件名和类名应该相同且UCfirst.So您的控制器文件名应该是 Test.php 而不是 test.php .

    • 如果您的网址无效 . 就像你使用没有index.php的链接,但你没有做它没有它的步骤(.htaccess,..) .

    Note :尝试使用您的链接 http://your_site_base_url/index.php/test 如果它不起作用意味着您有任何这些问题 .

相关问题