Managing multiple application folders with one index.php

There was a question in the CodeIgniter forums about management of multiple
application folders using just one index.php. I was interested in that so
got deeper in the problem and tried to resolve that. I found a solution and
this was mode_rewrite. Actually I applied a technique that I have never used
before – setting environment variables using htaccess and mod_rewrite. Here
is what exactly I did:

.htaccess file:

RewriteEngine on

RewriteCond $1 !^(index\.php)
RewriteRule ^([^/]+)/(.*)?$ - [E=PATH_APPLICATION:$1,NE]

RewriteCond $1 !^(index\.php)
RewriteRule ^([^/]+)/(.*)?$ /index.php?/$2 [L]

Using this .htaccess file I manage the hiding of the index.php file and the most
interesting part is setting the environment variable REDIRECT_PATH_APPLICATION
with the first segment of the accessed uri. So in the index.php I can access
$_SERVER['REDIRECT_PATH_APPLICATION'] which holds the first segment. This segment
shows me where is the application folder I need to use with this request. So
in the index.php I have the following:


$application_folder = "/var/www/".$_SERVER['REDIRECT_PATH_APPLICATION'];

This post is also available in: Bulgarian

  1. See this solution that I created because I had the same problem and now I have separated applications and continuous deploy via github.

    http://github.com/hafael/codeigniter.core

  2. I also approaching , it is the best plan greedy described above from you . Ability of a sign of artistic You have my aggressive in practice.

  3. The column , accounting for allowable actual address , it needs advice abundant advantageous for me . I am blessed rave reviews road your autograph post the acquisition .

  4. Please continue to acceptable plan of you, I only seem to suit you . Very good , additional articles Your attending physician in advance appearance .

  5. In addition to free speech, Apple argues that the Fifth Amendment’s Due Process clause prohibits the government from compelling Apple to create the new version of iOS. Apple argues that there is no court precedent for forcing a company to create something new, like GovtOS.

  1. No trackbacks yet.