Welcome Guest, Not a member yet? Register   Sign In
Separate hostname on same CI site
#1

[eluser]Unknown[/eluser]
I've been reading various articles on setting up multiple sites with the same CI codebase, but I'm a bit lost in the competing options so I just thought I'd ask.

Here is the situation: I have a primary site at www.example.com. I need to develop a second set of (primarily view) pages on a second hostname, such as simple.example.com, which will be basically the same website but more of a "lite" version of the original. 90% of the site will be the same code, especially the models. (This is all on one machine.)

One option is to create a second site and just symlink the files, but I'm using SVN and I really don't want to treat them separately because that's going to cause problems checking in/out code. What I really thought about doing is creating a controller in my primary site called simple.php and then using mod_write to point simple.example.com to www.example.com/simple since this needs to be hidden from the user (the user of the simple site should not see the real www.example.com site or really be aware it's there.)

I looked at the user guide on multiple sites with one CI installation, but it looked like it was actually using two separate sets of models/views etc, which isn't what I want.

Any opinions on what would be best?
#2

[eluser]Unknown[/eluser]
I think I answered my own question, I got it to work with a mod_rewrite, I just put this in my httpd.conf virtual host section


<VirtualHost *:80>
DocumentRoot /home/mainsite
RewriteEngine on
RewriteRule ^(.*)$ /index.php/simple$1 [NC]
ServerName simple.example.com
</VirtualHost>

so it's pointing the host now to the new controller, which works for me.

I guess my only consideration now is that everything's shifted --- since simple.example.com is now REALLY
www.example.com/simple -- the controller name is already taken -- so simple.example.com/test -- where as test would normally be the controller file is now a function in the controller, and on down the line.
#3

[eluser]BrianL[/eluser]
My first inclination is to not attempt this and to use more than one CI install and not the same one. Honestly, the whole point of CI is to have as small a footprint as possible so using more than one install should not be a problem.

My second inclination is that you're making it more complicated than necessary. "Test normally be the controller is now a function in the controller" what a nighmare! Instead create several virtual hosts with their own web directory and own index.php and alter the "system" setting in index.php directly to refer to the same CI install. Certainly you do not need to symlink anything. Just have both index.php pointing to the same system folder. Now the only problem is the default controller, which can be solved by having default controller point to some "routing" controller which checks the current_url of the page being viewed then routes to the appropriate controller.

By the way if you're using Debian-style Linux like Ubuntu, virtual hosts are created in sites-enabled and using a2ensite not in httpd.conf . If you want virtual hosts, debian-style is the way to go.
#4

[eluser]Federico BaƱa[/eluser]
If you put your controller files under /controllers/simple/, "test" stills the name of the controller and not the function.
So save test.php (controller) under /controllers/simple/ and then access it through www.example.com/simple/test.




Theme © iAndrew 2016 - Forum software by © MyBB