Search code examples
php.htaccesscodeignitersaas

Building a SaaS application in CodeIgniter like Shopify with custom domain alias


I am working on a SaaS application. We take Shopify / Magento Go etc as reference.

  • I used CodeIgniter PHP framework.
  • SaaS Methodology - Multiple database, single code-base

Our SaaS architecture is as follows:

SaaS Architecture

  • when a customer signup a database is build with his name and contain his specific databases.
  • when a customer signup he get a sub-domain (Ex: test1.example.com)
  • The customer can add his own domain that points to the system defined sub-domain. (Ex: test1.example.com to www.mydomain.com )

How to achieve this functionality?


Solution

  • For this you have to go through few configuration options.

    1. Configure DNS: Create sub-domain with *. (ask you host)
    2. You have to configure apache or .htaccess to point all requests coming to your domain point to same directory.
    3. Database Setting: Try to learn how to use multiple database in codeigniter.

    That's all. Enjoy!