Welcome Guest, Not a member yet? Register   Sign In
Multiple domains pointing to same CI application
#8

[eluser]Phil Sturgeon[/eluser]
The way I gave you above was a good way to keep your various sites easily manageable and scalable, but if you would like a "JUST databases" solution I have one of those too!

Just make a database config group for each site, then automatically work out which group to use from the server name.

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "rsi";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_unicode_ci";

$db['www.NewYorkSite.com']['hostname'] = "localhost";
$db['www.NewYorkSite.com']['username'] = "root";
$db['www.NewYorkSite.com']['password'] = "";
$db['www.NewYorkSite.com']['database'] = "rsi";
$db['www.NewYorkSite.com']['dbdriver'] = "mysql";
$db['www.NewYorkSite.com']['dbprefix'] = "";
$db['www.NewYorkSite.com']['active_r'] = TRUE;
$db['www.NewYorkSite.com']['pconnect'] = TRUE;
$db['www.NewYorkSite.com']['db_debug'] = TRUE;
$db['www.NewYorkSite.com']['cache_on'] = FALSE;
$db['www.NewYorkSite.com']['cachedir'] = "";
$db['www.NewYorkSite.com']['char_set'] = "utf8";
$db['www.NewYorkSite.com']['dbcollat'] = "utf8_unicode_ci";

// Grab the current domain config, or if there isnt one use the default
$active_group = in_array($_SERVER['SERVER_NAME'], array_keys($db)) ? $_SERVER['SERVER_NAME'] : "default";

?>

If you do it this way, make sure your htaccess redirects from http://NewYorkSite.com to http://www.NewYorkSite.com too ofc. Thats an easy one:

Quote:RewriteEngine on
RewriteCond %{HTTP_HOST} !^NewYorkSite.com$ [NC]
RewriteRule ^/(.*) http://www.NewYorkSite.com/$1 [L,R=301]


Messages In This Thread
Multiple domains pointing to same CI application - by El Forum - 12-05-2008, 09:30 PM
Multiple domains pointing to same CI application - by El Forum - 12-07-2008, 09:57 AM
Multiple domains pointing to same CI application - by El Forum - 12-07-2008, 10:15 AM
Multiple domains pointing to same CI application - by El Forum - 12-07-2008, 11:00 AM
Multiple domains pointing to same CI application - by El Forum - 12-07-2008, 03:56 PM
Multiple domains pointing to same CI application - by El Forum - 12-08-2008, 06:42 AM
Multiple domains pointing to same CI application - by El Forum - 12-08-2008, 05:07 PM
Multiple domains pointing to same CI application - by El Forum - 12-08-2008, 05:35 PM
Multiple domains pointing to same CI application - by El Forum - 12-08-2008, 05:55 PM
Multiple domains pointing to same CI application - by El Forum - 12-09-2008, 02:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB