For security reason codeigniter4 folder is made suchg a way that all the libraried and code folder is outside the public folder. By url only public folder is accesible.
To host it on share hosting your directory structure should look like this.
--home/root (sharehosting root directory)
|__ public_html (or your domain root folder)
| |__assets
| |__ index.php
| |__ .htaccess
|
|__ codeigniter (create a folder with any name you like)
|__ app(all the files and folder in app folder)
|__ system
|__ writable
|__ .env (dot env file here)
Now you need to change some values to up and running your codeigniter4 project
In public_html
folder index.php
file chnage the $pathsPath = FCPATH . '../app/Config/Paths.php';
to $pathsPath = FCPATH . '../codeigniter/app/Config/Paths.php';
In app/Config
folder App.php
file change $baseURL = 'http://192.168.0.111/';
to $baseURL = 'http://yourdomain.com/';
.
After this chnage your site will be up and running.
To deploy in subdomain and if your subdomain root folder lies in public_html then you should change $pathsPath = FCPATH . '../app/Config/Paths.php';
to $pathsPath = FCPATH . '../../codeigniter/app/Config/Paths.php';
in public_html/yourdomain
folder index.php
file, followed that directory structure remains same. Important: public folder content should be placed in your subdomain folder.