Hi guys, I just bumped to something I need to have nice a way how to handle mutiple applications using single CI core.
My setup:
I would like to use URL like "http://localhost/app2" and it should be directed to app2.php to properly run application and initialize app2.
For this purpose I use mod_rewrite:
After that I set indexPage for each app in this case $indexPage = 'index.php' and $indexPage = 'app2.php'
Now we need just add hook to IncomingRequest class to parseRequestURI method like this -> when checking for segments
What do you think ?
THX
My setup:
Code:
- /apps
- /app1
- /Config
- /app2
- /Config
- /common
- /Config
- /system
- /public
- index.php (defualt front controller)
- app2.php (second app front controller)
- .htaccess
I would like to use URL like "http://localhost/app2" and it should be directed to app2.php to properly run application and initialize app2.
For this purpose I use mod_rewrite:
Code:
# Convert first segment to front controller if exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^([^.*\/]*).*$
RewriteCond %{DOCUMENT_ROOT}/%1 -f
RewriteRule ^([^.*\/]*)(\/.*).*$ $1.php$2 [L,NC,QSA]
RewriteRule ^([^.*\/]*)$ $1.php [L,NC,QSA]
After that I set indexPage for each app in this case $indexPage = 'index.php' and $indexPage = 'app2.php'
Now we need just add hook to IncomingRequest class to parseRequestURI method like this -> when checking for segments
Code:
// or when first segment is equal to indexPage
elseif (strpos(trim($uri,'/'), $this->config->indexPage) === 0)
{
$uri = (string) substr(trim($uri,'/'), strlen($this->config->indexPage));
}
What do you think ?

THX