简体   繁体   English

Codeigniter 4 index.php

[英]Codeigniter 4 index.php

I have a question regarding CodeIgniter4.. Once copied all content from the folder, going to: 我有一个关于CodeIgniter4的问题。复制完文件夹中的所有内容后,将转到:

http://localhost/project-name/

It brings me to: This root page 它带我到: 此根页面

My question is, how can i point: 我的问题是,我该如何指出:

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

First make a local host like 首先将本地主机设为

<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>

and define the host too like the server name in the host file and point the folder you want to hit 并在主机文件中将主机定义为类似于服务器名称的主机,然后指向要单击的文件夹

I discovered that when I try to point all my url to public/index.php in my project it return error 404 based on it can't find my controller after rewriting my .htaccess to point to public/index.php in my project root directory. 我发现,当我尝试将我的所有URL指向项目中的public / index.php时,由于重写了.htaccess指向项目根目录中的public / index.php后,它返回错误404基于它找不到我的控制器目录。

This is how I solved my problem => 这就是我解决问题的方式=>
I move the index.php and the default .htaccess to my project root directory then I edit the index.php to locate my app directory 我将index.php和默认的.htaccess移到项目根目录,然后编辑index.php以找到我的应用程序目录
Eg 例如
index.php Default find this line index.php默认找到这一行

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


Change it to 更改为

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


I hope this work for you 希望这项工作对您有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM