Welcome Guest, Not a member yet? Register   Sign In
how to install CI4 in sub folder in shared hosting?
#1

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 ...
Reply
#2

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.
I would change this world, but God doesn't give me the source.
Reply
#3

(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 ...
Reply
#4

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.
I would change this world, but God doesn't give me the source.
Reply
#5

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
Reply
#6

(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
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#7

(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
Reply
#8

(This post was last modified: 02-01-2020, 09:40 AM by includebeer.)

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*
Reply
#9

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




Theme © iAndrew 2016 - Forum software by © MyBB