Welcome Guest, Not a member yet? Register   Sign In
How to have several sites use the same code
#1

[eluser]Andreas Krohn[/eluser]
I am just about to start a new project, and I am not sure what is the best design of my CI app...

The idea is to have several sites (20+ domains) running from the same backend. I want to have one admin panel, one database and just one set of code to run all the sites. If I need to install CI etc on each of the 20+ domains I am just not going to do it, and I am certainly not going to keep it updated going forward. I have thought about having a URL include on each of the 20 sites and then include code from a central CI installation, but I am not to keen on all the security issues that comes with a URL include.

Is there some other simple way I can have one central CI app feed many different sites without having to install a lot on each domain?
#2

[eluser]xwero[/eluser]
I don't know if one database is a good way to go, for security and maintainability reasons.
Security : one database means one hole and the data of all the sites are open for exposure.
maintainable : if you can choose between 50 or 500 tables which database do you want to check if anything went wrong? I guess the tables will be copied per domain to separate the data?

I think you can simlink the backend code form one domain to all the others.
#3

[eluser]Andreas Krohn[/eluser]
Each site is very small, and the whole application would have less than 10 tables anyway. I'd rather go with one database that I can keep up to date and protected than 20+ db's that I won't. The tables do not need to be domain specific since it is the same content structure on each of the 20 sites, just different acctual content.

I am not sure how I would simlink a domain to another & use CI, could you expand a bit on that?
#4

[eluser]xwero[/eluser]
first google result Smile
#5

[eluser]bramb79[/eluser]
Are all sites on different servers? Or just one server with 20+ domain names?

If you are on one server I would just map each domain to a different CI controller (and maybe looking into something like Matchbox), probably setting up each site within a different controller folder. You can then set up different config files for each site. Models etc. can then be freely shared.
#6

[eluser]Andreas Krohn[/eluser]
thanks for the google link, duh Smile

Yes, all the domains will be on the same server. Having different controllers/config files for each domain sounds interesting.
#7

[eluser]bramb79[/eluser]
Do you manage your own Apache server? In that case you can map the domains to different locations. What you can possibly do is create a directory for every site in which you store the index.php (the standard CI index.php that you find in your root folder). Your system directory path should be specified in there.

So for example:
domain1 - http://www.domain1.com - points to /www/domain1/
domain2 - http://www.domain2.com - points to /www/domain2/
CI dir can be in www/codeigniter/

Your index.php system folder name points to "../codeigniter/system/"

Of course, this asks for copying the index.php file 20 times, so still pretty ugly but it should work.

Next step is to somehow find out which site you are on (through the URL probably) and load the appropriate controller conditionally.

You could also already do the conditionals in the main index.php file - in that case, all the sites can point to the same directory.

Hope this is helpful... Smile
#8

[eluser]Clooner[/eluser]
I am working on a projects now and it just detects the domain in the routing file and routes accordingly
#9

[eluser]Andreas Krohn[/eluser]
Thanks bramb79, that was very helpful!

I do not manage the server, but it's all going to be on a host that already divides domains by directories as you describe. Uploading index.php 20 times is completely OK, since I after that has just one code base to worry about. Won't the setup you suggest create some problems though, since I will only have one config.php and thus only one base_url?
#10

[eluser]Andreas Krohn[/eluser]
thanks clooner. spread the index.php file to all 20 domains + edit the router file should do it.




Theme © iAndrew 2016 - Forum software by © MyBB