CodeIgniter Forums
how to install CI4 in sub folder in shared hosting? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: how to install CI4 in sub folder in shared hosting? (/showthread.php?tid=74471)



how to install CI4 in sub folder in shared hosting? - kingstyles - 09-28-2019

How to install CI4 in sub folder in shared hosting?
I want to access by this URL(without public folder):
example.com/myapp/controller/method ...


RE: how to install CI4 in sub folder in shared hosting? - Digital_Wolf - 09-28-2019

You should set the "DocumentRoot" option in HTTPD.conf your server settings, Example:
DocumentRoot = "%siteDir%/myapp/public/"
Or if you renamed the "public" folder to "myapp", then install something like this:
DocumentRoot = "%siteDir%/myapp/"
Where %siteDir% points to a domain folder.


RE: how to install CI4 in sub folder in shared hosting? - kingstyles - 09-28-2019

(09-28-2019, 04:08 AM)Digital_Wolf Wrote: You should set the "DocumentRoot" option in HTTPD.conf your server settings, Example:
DocumentRoot = "%siteDir%/myapp/public/"
Or if you renamed the "public" folder to "myapp", then install something like this:
DocumentRoot = "%siteDir%/myapp/"
Where %siteDir% points to a domain folder.

As i mentioned the host is shared... and we cannot edit  HTTPD.conf...
The host root dir contains some Apps folders and one of them is CI4:
public_html/frameworkX/...
public_html/frameworkY/...
public_html/CI4/...

Now, we want make CI4 URL access without 'public', like:
example.com/CI4/controller/method ...


RE: how to install CI4 in sub folder in shared hosting? - Digital_Wolf - 09-28-2019

Try doing it in a file .htaccess which will be located in the folder pointed to by your server, if you look at ci4/public/.htaccess it says that you can set the base directory using the parameter "RewriteBase", and also provides a link to the official documentation for configuring the server files.


RE: how to install CI4 in sub folder in shared hosting? - kingstyles - 09-28-2019

Finally i found a simple solution:
1- create index.php in the ci4 root folder that contain ( include 'public/index.php' )
2- then copy public/.htaccess to the root folder


RE: how to install CI4 in sub folder in shared hosting? - includebeer - 09-29-2019

(09-28-2019, 11:58 PM)kingstyles Wrote: Finally i found a simple solution:
1- create index.php in the ci4 root folder that contain ( include 'public/index.php' )
2- then copy public/.htaccess to the root folder

You do not absolutely need a directory named "public". You can reorganize the directories like you want. You just need to have a public and a private directory. 

You can put all the content of the "public" directory anywhere you want, with the name you want, and then set the path for the private directory in index.php :
Code:
// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../my-ci4-webapp/app/Config/Paths.php';
// ^^^ Change this if you move your application folder



RE: how to install CI4 in sub folder in shared hosting? - kingstyles - 09-29-2019

(09-29-2019, 06:38 AM)includebeer Wrote:
(09-28-2019, 11:58 PM)kingstyles Wrote: Finally i found a simple solution:
1- create index.php in the ci4 root folder that contain ( include 'public/index.php' )
2- then copy public/.htaccess to the root folder

You do not absolutely need a directory named "public". You can reorganize the directories like you want. You just need to have a public and a private directory. 

You can put all the content of the "public" directory anywhere you want, with the name you want, and then set the path for the private directory in index.php :
Code:
// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../my-ci4-webapp/app/Config/Paths.php';
// ^^^ Change this if you move your application folder

Thanks alot


RE: how to install CI4 in sub folder in shared hosting? - Gwendolyn - 01-31-2020

One additional measure to take in production environments is to disable PHP error reporting and any other development-only functionality. In CodeIgniter, this can be done by setting the ENVIRONMENT constant, which is more fully described on the environments page *SPAM link removed*


RE: how to install CI4 in sub folder in shared hosting? - alexdevstudio - 04-03-2020

Here is the video tutorial that shows exactly the steps.
https://www.youtube.com/watch?v=k943H5OiIdE[Video: https://www.youtube.com/watch?v=k943H5OiIdE]