Welcome Guest, Not a member yet? Register   Sign In
Unlimited applications, one CI
#1

[eluser]isabelle[/eluser]
Hy all,

I've read the doc about using CI for more than one application but i'm wondering how to display the right website dynamicly.

I now i have to specify the application folder in the index file but if i have different domain names, do i have to check the uri?

like this :

Code:
if($_SERVER["REQUEST_URI"] == "theadress"){
$application_folder = "application/repertory";
}
else if(...)
{
...
}

It works for two or three applications but for more, is there a specific way to work like that? (the applications are created manually, not dynamicly like blogs)

Thanks in advance for your reply,
#2

[eluser]binlid[/eluser]
That would be done in your web server's configuration, virtual hosts in apache's case:
Code:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

Each DocumentRoot would have its own index.php pointing to their respective application folder.
#3

[eluser]terdelyi[/eluser]
Maybe you only need to create a new directory (example app2) and copy another index.php to there.
In app2/index.php you have to edit system path to the CI root (in that case ../system) and modify the application path.

If you use .htaccess to remove index.php not forget to add a new exception for RewriteCond row:

Code:
RewriteCond $1 !^(index\.php|images|app2|robots\.txt)
#4

[eluser]Buso[/eluser]
[quote author="isabelle" date="1194658717"]Hy all,

I've read the doc about using CI for more than one application but i'm wondering how to display the right website dynamicly.

I now i have to specify the application folder in the index file but if i have different domain names, do i have to check the uri?

like this :

Code:
if($_SERVER["REQUEST_URI"] == "theadress"){
$application_folder = "application/repertory";
}
else if(...)
{
...
}

It works for two or three applications but for more, is there a specific way to work like that? (the applications are created manually, not dynamicly like blogs)

Thanks in advance for your reply,[/quote]


I use something like this, I hope it makes sense:

Code:
// extra apps
$applications = array(
    array('site' => 'app2', 'uri'    => '/uri2'),
    array('site' => 'app3' , 'domain' => 'mydomain3.com')
);

$application_folder = "../application";

    foreach($applications AS $a) {
        if(isset($a['uri'])) {
            if( 0 === stripos($_SERVER['REQUEST_URI'], $a['uri']) ) {
                $application_folder = "../application_" . $a['site'];
            }
        } else if(isset($a['domain'])) {
            if( 0 === stripos($_SERVER['SERVER_NAME'],$a['domain'])) {
                $application_folder = "../application_" . $a['site'];
            }
        }
    }

for more apps, I just add them to the array, with the corresponding uri or domain. Then in config.php you have to make the base_url fit this

you could add an 'application_folder' key to the array if you want different names for the folders. I just feel that using the 'application_' prefix is more tidy




Theme © iAndrew 2016 - Forum software by © MyBB