CodeIgniter Forums
Handing Multiple Sites - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Handing Multiple Sites (/showthread.php?tid=30842)



Handing Multiple Sites - El Forum - 05-27-2010

[eluser]Insa[/eluser]
I'm trying to run multiple applications with CI, a site and an admin section for said site.

I have 2 application folders: 'application/site' and 'application/admin', and I would like them to be accessed on site.com and site.com/admin.

the article in the user guide about this helped me get the 'site' part working properly, but it wasn't clear on what to do for the 'admin' app.

The problem I'm having is that I'm unsure where to put the index.php file for admin. I can't make a directory 'admin' and place the index file in there, because if I go to site.com/admin, CI will look at 'site/controllers/admin.php' instead of where I want it to look.
I also tried renaming index.php to admin.php and putting it 'site/controller's, but all I got was error messages because it tried to define statics etc etc twice.

How do you guys handle this problem? I've been struggling with it for the past few hours, and as I can't figure it out myself I figured I'd give these forums a try.

Thanks in advance!


Handing Multiple Sites - El Forum - 05-27-2010

[eluser]WanWizard[/eluser]
It's not how I would do it, but you can make this work by modifying your rewrite rules.

Instead of rewriting everything to /index.php, create a condition that matches /admin/..., and rewrite that to /admin/index.php. Then add a condition to the already existing rewrite, excluding /admin (to make sure all links starting with /admin are not rewritten to your site index.php).


Handing Multiple Sites - El Forum - 05-27-2010

[eluser]Insa[/eluser]
I considered that, but surely there's an easier/better way?

How do you guys do this?


Handing Multiple Sites - El Forum - 05-27-2010

[eluser]cahva[/eluser]
Instead of creating two applications mentioned in the userguide, you could use modular separation.

I always use modular separation to create backend(admin) to sites.


Handing Multiple Sites - El Forum - 05-27-2010

[eluser]maltzurra[/eluser]
You can also do the following if you want some webs managed at the same time (in case you share DB):

- Take "application" folder to root, at the same level/folder as system.
- Create "application1" at the same folder
- Inside "index.php" change the following:

$application_folder = "application";

to

switch($_SERVER['HTTP_HOST']) {
case 'www.mysite1.com': $application_folder = "application1"; break;
case 'www.mysite.com':
default: $application_folder = "application"; break;
}


(now you can easily add sites)

- Check both config.cfg files and make sure both base_url are properly set.
- Forward both mysite.com & mysite1.com to your machine.
- Create an admin panel and have fun Smile


That being said, I would actually give a try to what said above.

Cheers to everyone by the way!


Handing Multiple Sites - El Forum - 05-27-2010

[eluser]Insa[/eluser]
Awesome, thanks a lot


Handing Multiple Sites - El Forum - 02-25-2011

[eluser]rawoke083[/eluser]
Hi I have a sort of similar method.
But with this method I share, models,config,web folder

http://ellislab.com/forums/viewthread/181990/


Handing Multiple Sites - El Forum - 02-25-2011

[eluser]cmgmyr[/eluser]
Take a look at Phil's post here - option #3. Instead of Matchbox, use Modular Extensions here

I'm using this setup and it works out really well. If you have any questions, just let me know.

-Chris


Handing Multiple Sites - El Forum - 02-25-2011

[eluser]gowrav vishwakarma[/eluser]
http://codeigniter.com/wiki/Multiple_Sitessubdomains_for_Single_CI_system/

Hope this helps