Multiple Sites in One Single CodeIgniter Installation

Bismillah

References:
- http://codeigniter.com/wiki/Multiple_Applications/

In case you have several projects (e.g: project1 and project2) and
want to put them in one single codeigniter installation
0. After you've extracted the CI's files, you will get these folders:
system, user_guide.; and these files: index.php, license.txt.
1. Create folder project1 and project2 in your Document Root, they
will look like this.

project1/
project2/
system/
user_guide/
index.php
license.txt


2. Create project1.php and project2.php (any other names is fine, but
let's keep it simple for now). These files are actually copies of
index.php (so you must make sure its content is the same).

project1/
project2/
system/
user_guide/
index.php
license.txt
project1.php
project2.php


3. Copy all contents in system/application/ to each of your project
(project1 and project2).
project1/
config/
controllers/
errors/
.
.
.
views/
project2/
config/
controllers/
errors/
.
.
.
views/
system/
user_guide/
index.php
license.txt
project1.php
project2.php


4. Set application folder of each projects. That means you have to
change the value of $application_folder to "project1" in project1.php
and "project2" in project2.php

5. Almost done. So you now have http://localhost/project1.php for
Project1 and http://localhost/project2.php for Project2.

6. Say you want to get rid of that ridiculous "blablah.php" in your
url, we have to play with .htaccess file for URL rewriting.


RewriteEngine On
RewriteBase /

RewriteRule ^project1$ /project1.php [L]
RewriteRule ^project1/(.*)$ /project1.php/$1 [L]

RewriteRule ^project2$ /project2.php [L]
RewriteRule ^project2/(.*)$ /project2.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]


That's it. Any correction is welcomed.

Tidak ada komentar:

Posting Komentar

speak now or forever hold your peace

About Me