Running Multiple Applications with one Codeigniter Installation - Dirctory Structure

Hi All,

Any help on this will be appreciated. I have read the user guide topic on this subject and am trying to create a directory structure as follows.

..and so on.

Each user is in their own folder w the CI/applications folder copied into it. I want them to all use the same CI/system dir. I understand that this is not how the user guide says to do it, but I want to know if it's possible.

I have it set up to the point that a simple page will display, but as soon as methods are called that are stored in the system/dir all the paths point to codeigniter/applications not to webroot/joes_bar/applications (for example).

Is it possible to set it up the way I have noted?


Your setup (as you described it) is correct.
All websites will use same system/* folders (all classes, functions and so on);
All files within each website will remain available only for that website.

Have fun!

[eluser]Daniel Moore[/eluser]
It seems like you've got your user's directories each in their own subdirectory of the actual web server, which would be pointed to like:

That is, if I understood you correctly. If this is the case, then your index.php file should reside in each directory. One for "joes_bar", one for "wendys_wicked_ways", etc. You will also need a separate .htaccess file in each user subdirectory, correctly configured to redirect to that particular subdirectory, or your controllers will not point to the right place.

Your index.php files should also have:
$system_path = "../system";
$application_folder = "applications";

I noticed you called the "application" folder "applications". It would probably be best to just leave it at "application" to prevent future confusion, especially when upgrading.

If you go with this system, make sure you place an .htaccess file in your system folder that has the line, "deny from all" to prevent people from browsing to it, since it is not outside your web root.

Thanks for the reply. Yes to naming the application folder singular rather than plural- that was just a typo on my part. I am on a windows/iis server not apache so there is no .htaccess file. Isapi rewrite might be a option but it looked way complicated and neither is actually necessary.

Here's the answer for anyone else who is interested. If you are familiar with the following instructions in the user guide skip down to the section with the heading *************Here's what's missing from the user guide**************.

Setup your directory structure as the user guide indicates (
Quoting the User Guide: “For example, let's say you want to create two applications, "foo" and "bar". You will structure your application folder like this:
To select a particular application for use requires that you open your main index.php file and set the $application_folder variable. For example, to select the "foo" application for use you would do this:
$application_folder = "application/foo";
Note: Each of your applications will need its own index.php file which calls the desired application. The index.php file can be named anything you want. “

*************Here's what's missing from the user guide**************
All of the user guides instructions work exactly as advertised. However there are a couple of issues.
1.Copy your index.php file to system/application/foo/.
2.In the index.php file set the path to the application folder exactly as they state.
$application_folder = "application/foo";
The php figures out the absolute path so you don’t have to.
3.You need to set the path to the system dir which works differently and this is what is confusing. The path to the system dir is relative to where your index.php file is. If your index.php file is in system/application/foo, as recommended, then set the system path as follows.
$system_folder = "../../../system";
4.You must set the path of the index file even if you do not rename it. Since it is now located in the application/foo dir instead of the default codeigniter dir, the path is set as follows. Open the config.php file located in \system\application\foo\config\config.php. Find $config['index_page'] and set it as follows.
$config['index_page'] = "system/application/foo/index.php";

5.Renaming the index.php file is fine as the user guide states. Follow the same procedure as in the step above but use the new index.php filename. So the entry in config.php should be set as follows.
$config['index_page'] = "system/application/foo/<your index file name>.php";
In my testing the following also works only if you rename the index.php file.
$config['index_page'] = " <your index file name>.php";
However there’s no sense taking chances so in my opinion it’s best to include the path.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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