php - Codeigniter 4 index.php
问题描述
我有一个关于 CodeIgniter4 的问题。从文件夹中复制所有内容后,转到:
http://localhost/project-name/
它把我带到: 这个根页面
我的问题是,我该如何指出:
http://localhost/project-name/ to http://localhost/project-name/public/index.php
解决方案
我发现当我尝试将我的所有 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';
我希望这对你有用
推荐阅读
- amazon-web-services - AWS Auto Scaling 组是否会在终止 EC2 之前关闭它的操作系统?
- html - 视频不在现场播放,但在其他地方播放
- excel - 如何将两个工作表(它们之间具有不同的数据)合并到一个数据透视表中?
- node.js - Socket IO 套接字属性未保存
- unix - 在 ksh shell 脚本中使用 dbisqlc 捕获 Sybase IQ SQL 执行中的错误
- java - Gradle:对构建和测试使用不同的 jre
- python - 如何在谷歌协作笔记本中显示输出?
- node.js - 如何为其他字段的每个值获取字段的不同值?
- docusignapi - 标记的 DocuSign SOAP API 设置默认值
- angular - 角度路由解析器 rxjs