codeigniter-extended
codeigniter-extended copied to clipboard
Serving multiple site using single installation
Is it possible to use a single installation of cix to Serve multiple site. I want to serve www.site1.com, www.site2.com from single installation.
If your requirement is to serve multiple site from single document root, yes it is possible. By implementation codeigniter allow us to place our application directory to any where. So we can add some logic layer before defining our $application_folder
. First we need to install CIX
Then we could use the following sample file:
//web/multisite.php
<?php if (!defined('CIX_APP_CONFIG_LOADER')) exit('No direct script access allowed');
$hostname =strtolower($_SERVER['SERVER_NAME']);
$hostname = preg_replace('#^www\.(.+\.)#i', '$1', $hostname);
//Here is the logic layer
switch ($hostname)
{
case 'site1.com':
case 'www.site1.com':
$application_folder = 'site1';
break;
case 'site2.com':
case 'www.site2.com':
$application_folder = 'site2';
break;
default:
$application_folder = 'application';
}
$application_folder = '../src/'.$application_folder;
then replace the $application_folder = '../src/application';
line with
include_once "multisite.php";
NB: You can use the trick with normal installation of your codeigniter applicaiton. You just need to replace the code from index.php
then.