Welcome Guest, Not a member yet? Register   Sign In
Handing Multiple Sites

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!

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).

I considered that, but surely there's an easier/better way?

How do you guys do this?

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.

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";


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!

Awesome, thanks a lot

Hi I have a sort of similar method.
But with this method I share, models,config,web folder


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.


[eluser]gowrav vishwakarma[/eluser]

Hope this helps

Theme © iAndrew 2016 - Forum software by © MyBB