Welcome Guest, Not a member yet? Register   Sign In
How do I? one Application, multiple subdomains
#1

[eluser]dcheslow[/eluser]
I'd like your thoughts and advice on how to do the following:

I want to use subdomains to customize for different groups of users so that mysite.com goes to the main site and yourpart.mysite.com goes to the main site with a REQUEST variable set indicating that the data for "yourpart" should be used. "yourpart" will have different data, different skin.... but the same application.

I can setup the subdomain easily enough - yourpart.mysite.com tries to load from the /yourpart/ directory. So I need to have at least index.php in the /yourpart/ directory with the defined paths all changed to prepend a "/..". And, of course, I need to set the REQUEST variable.

My questions are: have you done this? Run into any problems? Anything I've forgotten that I need to do?

I can't find any examples of people doing this, so I am suspicious that maybe there's a reason that I don't know about.

All suggestions/comments welcome.

Thanks,

=dave=
#2

[eluser]Matthew Lanham[/eluser]
We do this on quite a large overseas property portal, its not using codeigniter, but the principle is the same, we have 73 subdomains and use the first section i.e.(*).domain.com to define which country the site should be customised for.....

Never had any issues, and it works well, 1 code base, 73 domains...
#3

[eluser]sikkle[/eluser]
Hey dscheslow,

Indeed you have several possibility with that.

From my own experience, the easiest tricks i find to handle that is a hooks to set general config variable.

Also, even if it's not perfect because that mean a bit of hack, but not real hack honestly, if you use one different index.php for each subdomains, that mean you can pass information as constant for your apps.

This could easyly define the layout to use, the data to grab etc. etc.

I think that give you two possibility, i don't know if other people got some better idea, but worth a try Smile

good luck !
#4

[eluser]evanwalsh[/eluser]
Check this out
#5

[eluser]dcheslow[/eluser]
Thanks to all,

Evan, that posting refers to is almost exactly the opposite of what I want to do. That post is talking about mapping different subdomains to DIFFERENT controllers. What I was asking about was mapping different subdomains to the SAME controllers (after setting a variable).

It ended up being pretty easy...

1) I set up a subdomain called 'mypath',
2) copied index.php into the '/mypath/' directory,
3) changed the value of the defined value'system' to '../system',
4) parse out the subdomain name and save it in a $_REQUEST variable

.... everything else just worked out... SWEET!

I had a bit of trouble configuring for the development environment... couldn't get 'mypath.localhost:8888' to parse out correctly. Fortunately, I just use my handy-dandy site object to rewrite the value of '$myself' so that I can use the subdirectory notation in development:

localhost:8888/mypath/index.php

When I switch to the server with the subdomains defined, it just magically starts translating.

I love codeigniter <<insert misty-eyed sentimentality here >>




Theme © iAndrew 2016 - Forum software by © MyBB