[英]Codeigniter 4 index.php
我有一个关于CodeIgniter4的问题。复制完文件夹中的所有内容后,将转到:
http://localhost/project-name/
它带我到: 此根页面
我的问题是,我该如何指出:
http://localhost/project-name/ to http://localhost/project-name/public/index.php
首先将本地主机设为
<VirtualHost *:80>
ServerAdmin admin@projectName
DocumentRoot "C:/xampp7/htdocs/projectName"
ServerName projectName.local
ServerAlias projectName.local
ErrorLog "C:/xampp7/htdocs/school/projectName.local-error.log"
CustomLog "C:/xampp7/htdocs/school/projectName.local-access.log" combined
</VirtualHost>
并在主机文件中将主机定义为类似于服务器名称的主机,然后指向要单击的文件夹
我发现,当我尝试将我的所有URL指向项目中的public / index.php时,由于重写了.htaccess指向项目根目录中的public / index.php后,它返回错误404基于它找不到我的控制器目录。
这就是我解决问题的方式=>
我将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';
希望这项工作对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.