0

I have developed a "point of sale" kind of application for client in codeigniter. This application is hosted on some domain name e.g. www.example.com. The application is all done and working perfectly. Now the client want other companies (like his company) to use this application but with their own sub-domain (e.g. abc.example.com) and their own database (database structure will be cloned for each company) which will be configured at runtime when the company will fill a certain form. The workflow will be as follows:

  1. A company will make a request to client that it wants to use our app by filling a certain form.
  2. After we receive a request from some company, we want to automatically create a subdomain for it, copy our database and create a new database for that sub domain and make proper changes in codeigniter so that it can connect to the new database.

How can I achieve this kind of functionality?

1 Answer 1

0

I assume your structure looks like this?

/root/codeigniter
    /application
        /controllers
        /models
        /views
        /everything else
    system
        /CI system stuff

/root/public_html
    /subd1.example.com/index.php
    /subd2.example.com/index.php

If so then just point the index.php files to the CodeIgniter subdirectory

In index.php add the following information accordingly:

define('DBNAME', 'subd1_db');
define('DBUSER', 'subd1_username');
define('DBPASS', 'subd1_password');

Now in /application/config/database.php you need to do:

$db['default']['hostname'] = DBNAME;
$db['default']['username'] = DBUSER;
$db['default']['password'] = DBPASS;

subd stands for subdomain

2
  • Which index.php files should I point to Codeigniter subdirectory and how should I point them? Apr 9, 2014 at 19:30
  • 5 years now.. @HarisurRehman if you did find a solution will you answer your question please
    – nab
    Jun 15, 2019 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.