Part of the EllisLab Network
   
 
multiple sites, 1 codebase, not using symlinks
Posted: 11 August 2009 12:52 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  210
Joined  01-31-2008

I was just reading this - http://codeigniter.com/forums/viewthread/56436/ - and I’m wondering if there are any “gotchas” i need to consider for my solution. because the solution for my needs is so easy, works, and is so simple ... it’s got to be wrong! lol

i have an account on the rackspace cloud (formerly mosso) and i have the need to host several blog/cms style sites for my clients ... but i want all these sites to load the same CI install and app folder. so we are talking ... carbon copies with their data stored in a database and unique templates are loaded based on the client ID.

my cms allows different templates for different user’s pages, this all works already. if you need more info about this let me know. sites will have the same structure.

so basically, i create one master CI install ... it houses everything. i set the base_url like this ...

$config['base_url']    = (isset($_SERVER['HTTPS']) ? 'https://' 'http://').$_SERVER['HTTP_HOST']."/"

we will call this install ... MASTER.

now, each new CLIENT site, which i’ll call client_01, client_02 etc ... (all hosted on the same cloud account) has this for their index files ...

<?php

    
include('/mnt/mystore/xxxxxxxx/www.master.com/web/content/index.php');

?> 

and their .htaccess files ...

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase 
/

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

</IfModule

so when i pull up http://www.client_01.com ... it produces the page as if I got it from http://www.master.com but the base_url is rendered as http://www.client_01.com this .works perfectly ... like scary well!

the .htaccess on the client ensures everything routes ... etc ... it all works, posting to forms works fine etc.

so i’m thinking ... i just fetch the proper items in each controller from a table based on the base_url ... and i can make the appropriate queries once i get an ID based on the base_url.

so before i get busy ... does this sound viable? any security risks? will something stop me cold 50% into this?

anyways ... here’s to CI! it rocks!

oh ... and 1 more question ... will hosting assets like CSS, JS and Images be problematic if I link them to the master domain instead of copying them over? I rather not copy ... and I rather not use .htaccess trickery ... as it would seem to me that it would cause some CPU load to run every call against htaccess.

 Signature 

Greg Guepy - Skattabrain

Profile
 
 
Posted: 11 August 2009 02:01 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
RankRankRank
Total Posts:  663
Joined  08-26-2006

If You want to use Flash assets (video) You either need to copy them to the client domain or You need to specify a cross-domain policy file.

Don’t know if You need to do the same for some AJAX loaded content.

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

Profile
 
 
Posted: 11 August 2009 02:21 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  210
Joined  01-31-2008

ajax seems fine as it’s working perfectly… but to be frank, i need crash course in cross site scripting.

$config['global_xss_filtering'TRUE

i also use xss_clean in all validation rules.

 Signature 

Greg Guepy - Skattabrain

Profile
 
 
Posted: 11 August 2009 02:25 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
RankRankRank
Total Posts:  663
Joined  08-26-2006
skattabrain - 11 August 2009 06:21 PM

... i need crash course in cross site scripting.

Same with me.

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

Profile