.htaccess - Setting database dynamically according to sub-domain URL in codeigniter? -


i working on codeigniter site.i have 1 single application application used various user each user having own db(its own clients also).i need way how approach cloud system. have single copy of application folder , difference in db each user. have tried creating subdomain directory in codeigniter , writing index file , htaccess file can access original application.but need subdomain path in url , way how connect database according subdomian url path.

htaccess file.

rewriteengine on  rewriterule /test/(.*) /$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php 

which way should follow complete work.please in advance.

here's do:

in config/database.php, define set of different db settings, picked based on domain. can adjust/extend easily.

if($_server['server_name'] == 'www.stagingserver.com'){   $active_group = "staging";   $db['staging']['hostname'] = "95.xxx.xxx.xxx";     } else {   $active_group = "default"; }  $db['default']['hostname'] = "localhost:8889"; $db['default']['username'] = "root"; $db['default']['password'] = "root"; $db['default']['database'] = "database"; $db['default']['dbdriver'] = "mysql"; $db['default']['dbprefix'] = ""; $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_general_ci";  $db['staging']['username'] = "movers_user"; $db['staging']['password'] = "staging_user"; $db['staging']['database'] = "staging_database"; $db['staging']['dbdriver'] = "mysql"; $db['staging']['dbprefix'] = ""; $db['staging']['pconnect'] = true; $db['staging']['db_debug'] = true; $db['staging']['cache_on'] = false; $db['staging']['cachedir'] = ""; $db['staging']['char_set'] = "utf8"; $db['staging']['dbcollat'] = "utf8_general_ci"; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -