[eluser]CroNiX[/eluser]
[quote author="newtonianb" date="1293259879"]I have several fields in config.php, database.php and constants.php that are different when i publish my site to server.
How can I make it smart and have it automatically pick the right one based on lets say hostname.
I tried if(strpos(base_url(),"localhost") === false)
but base_url() isn't working in these files, it actually seems to only work inside database.php
What else can I do?[/quote]
In my index.php, at the top, I do:
Code:
define('LIVESITE', ($_SERVER['HTTP_HOST'] === strtolower('www.yoursite.com')) ? TRUE : FALSE);
Then, globally, you can:
Code:
if(LIVESITE)
{
//something for the live site
}
else
{
//something for your dev site
}
I also use it to define all of my config database setting and other variables, such as base_url based upon that setting.
Code:
$db['default']['username'] = (LIVESITE) ? 'the_live_site_username' : 'the_dev_site_username';
$db['default']['password'] = (LIVESITE) ? 'the_live_site_password' : 'the_dev_site_password';