• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shared controllers between domain and subdomain

#1
[eluser]Unknown[/eluser]
Hi everyone.

I have a big doubt regarding domain and subdomains..

I have a domain and 3 subdomains..

example.com -> www
bla.example.com -> www/bla/
ble.example.com -> www.ble/
bli.example.com -> www.bli/

The domain aims for the www folder, bla subdomains aims to bla folder inside www folder.

My question is bla,ble,bli sites will be quite similiar, same controllers, same models.. same everything, the only thing that will change on them is the type of category..something like

bla.example.com
category = "a";

ble.example.com
category = "b";

bli.example.com
category = "c";

All queries are going to be the same, but in each site they will search for that specific category.. My question is.

Do i need to install codeigniter in each of the subdomain folder, and copy paste all the project and just change the variable that's defining the category?

Do i have the possibility to have 1 install only of codeigniter and define a variable for each subdomain i am going to?

I need some sugestions,

Best Regards.


#2
[eluser]CroNiX[/eluser]
What you could do is symlink the directories for each sites directory structure to point to a common codebase elsewhere on the system. And then in the application check the value of $_SERVER['HTTP_HOST'] or something to determine what server it's being run on and load the appropriate things for that site.

so maybe

/home/codeigniter <-your real CI installation
/home/codeigniter/system
/home/codeigniter/application
/home/codeigniter/index.php <-set environment or define variable based on $_SERVER['HTTP_HOST'] value
/home/site1/system (symlink points to /home/codeigniter/system)
/home/site1/application (symlink points to /home/codeigniter/application)
/home/site1/index.php (symlink points to /home/codeigniter/index.php)
/home/site2/system (symlink points to /home/codeigniter/system)
...

I do this for over 175 real estate agent websites. They all run off of a single codebase on the same server, and just load the appropriate data for the real estate agent base off of the domain name and controller it's being called from. It's kind of a multisite CMS.

#3
[eluser]CroNiX[/eluser]
Another possible option is to just set the "application" and "system" directories to a common one in index.php. And then just copy the index.php to each site, which would be the only file you'd need in the dir.

In index.php:
$system_path = '/home/codeigniter/system';
$application_folder = '/home/codeigniter/application';


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.