Welcome Guest, Not a member yet? Register   Sign In
Same Installation folder for different sites (config.php and database.php)
#1

Hi !

Someone has tested or configured, multiple vhosts (apache)

ex:
zone1.mydomain.com

zone2.mydomain.com

both documentroot points to the same folder
but i need to have different config.php and database.php

Some idea ?

Thanks
Reply
#2

You can check what subdomain ist active and then make a switch in the config.php and database.php
Somthing like this quick an dirty snippet

PHP Code:
$subdomain explode('.'$_SERVER['HTTP_HOST']);
if (
$subdomain[0] != 'www' && count($subdomain) == 3)
{
    if (
$subdomain[0] == 'zone1')
    {

    }
    
//etc.
}
else
{
    
// no subdomain


Reply
#3

If you can alter the server configuration to set a variable, you can always use:
Code:
SetEnv CI_ENV zone1
(obviously you'd want to set CI_ENV to zone2 in the other subdomain)

Of course, if you can't do that, you could still set the environment at the top of the index.php file using Rufnex' code to detect the subdomain.

Once the environment is set, you can just add 'zone1' and 'zone2' to the list of environments in your index.php (to get the error reporting setup correctly) and load your config files from /application/config/zone1/ and /application/config/zone2/.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB