• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why CI4 Cannot Run in a Subdirectory?

#1
Question 
Hi.

I've read somewhere that CI4 is not supposed to be run in a subdirectory (like Laravel?). What is the reason for this behavior?

In my previous experience, when I created a website for a client using CI3 or Wordpress, some clients usually want the staging version is uploaded to a subdomain subfolder (like example.com/staging/). What is the solution to this?

Thanks.
Reply

#2
(12-25-2018, 05:58 AM)avicenna Wrote: Hi.

I've read somewhere that CI4 is not supposed to be run in a subdirectory (like Laravel?). What is the reason for this behavior?

In my previous experience, when I created a website for a client using CI3 or Wordpress, some clients usually want the staging version is uploaded to a subdomain (like example.com/staging/). What is the solution to this?

Thanks.

Perhaps you misread or the source was faulty. There is no "must be this way" file structure for CI4. This documentation describes how to relocate the application directory. Right below that is explained how to manage multiple apps which is what you describe as a staging version.
Reply

#3
If you access your app as xxx/myapp/public, then you are unnecessarily exposing the other folders in your app, eg. xxx/myapp/writable, unless you take care to configure things properly, eg with .htaccess files everywhere.

If you want to access your app as xxx/myapp, you might get away with a symbolic link of WEBROOT/myapp to WHEREVER_IT_REALLY_IS/public, but that is more work for you.

A better practice is to use subdomains, eg staging.xxx.com, rather than xxx.com/staging/public.

Another argument for mapping an app to a subdomain is for asset references. With a subdomain, '/images/abc.jpg' refers to the "images" folder inside your "public". With a directory mapping, then 'images/abc.jpg' would refer to 'public/images/abc.jpg' for the URL '', but to 'public/index.php/images/abc.jpg' if you aren't stripping index.php. It gets worse if you are using URI segments to pass parameters.

How does this differ from Laravel (or any of the other major frameworks)? I am curious Smile
Reply

#4
By the way, "example.com/staging" is NOT a subdomain, that refers to a subfolder. "staging.example.com" is a subdomain of "example.com"
Reply

#5
And if you move the ./application and system folders you need to tell index.php
were they are located by changing there paths in index.php
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
(12-25-2018, 09:57 AM)dave friend Wrote:
(12-25-2018, 05:58 AM)avicenna Wrote: Hi.

I've read somewhere that CI4 is not supposed to be run in a subdirectory (like Laravel?). What is the reason for this behavior?

In my previous experience, when I created a website for a client using CI3 or Wordpress, some clients usually want the staging version is uploaded to a subdomain (like example.com/staging/). What is the solution to this?

Thanks.

Perhaps you misread or the source was faulty. There is no "must be this way" file structure for CI4.  This documentation describes how to relocate the application directory. Right below that is explained how to manage multiple apps which is what you describe as a staging version.

Maybe, "staging version" is wrong words for this. I mean, it is possible to run the application in a sub-folder (not subdomain)?
Reply

#7
(12-25-2018, 10:15 AM)ciadmin Wrote: By the way, "example.com/staging" is NOT a subdomain, that refers to a subfolder. "staging.example.com" is a subdomain of "example.com"

Sorry, it was a typo, I mean sub-folder (example.com/staging), not a subdomain.

But it seems the easiest way is by just setting a subdomain.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.