首页 > 解决方案 > Codeigniter 4 index.php

问题描述

我有一个关于 CodeIgniter4 的问题。从文件夹中复制所有内容后,转到:

http://localhost/project-name/

它把我带到: 这个根页面

我的问题是,我该如何指出:

http://localhost/project-name/ to http://localhost/project-name/public/index.php

标签: phpcodeigniter

解决方案


我发现当我尝试将我的所有 url 指向项目中的 public/index.php 时,它会返回错误 404,因为它在重写我的 .htaccess 以指向项目根目录中的 public/index.php 后找不到我的控制器目录。

这就是我解决问题的方法=>
我将 index.php 和默认的 .htaccess 移动到我的项目根目录然后我编辑 index.php 以找到我的应用程序目录
例如
index.php 默认找到这一行

// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../app/Config/Paths.php';


将其更改为

// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . './app/Config/Paths.php';


我希望这对你有用


推荐阅读