User Subdomains with only one CI core |
[eluser]Dan Tdr[/eluser]
Hello, I know this issue has been talked about over and over again, sorry for opening another topic on it, but i just started with CodeIgniter and i need some guiding, if you can guide me to a proper topic/tutorial that will help me with what i need, i would be grateful. So basically what i need is : - only one core CI with multiple subdomains. - a script that will autocreate a folder (that will contain userdata like images) and make it into a subdomain. i know about the wildcard dns thing, i can set it on my server, but i don`t know how. - a mode rewrite maybe So that`s about it, if anything is not clear please let me know. Thanks, Dan
[eluser]bretticus[/eluser]
There are so many ways to implement this that I recommend that you just google it. Once you can reference the base path, you can make logic decisions such as which views to use, etc. mod_rewrite is not relevant because you really don't want to redirect anything by host header as you're depending on the host header to know which site content to display.
[eluser]Dan Tdr[/eluser]
the problem is that i did google it, and i searched several pages, i read about 2-3 hours about it until i was so confused about it that i thought someone could point me to something that is working and is explained. I found several articles but there were confusing and not so well explained, i got the base path url but i just don`t know the rest.
[eluser]bretticus[/eluser]
[quote author="dan.tdr" date="1283222692"]the problem is that i did google it, and i searched several pages, i read about 2-3 hours about it until i was so confused about it that i thought someone could point me to something that is working and is explained. [/quote] Then I recommend going with the least confusing one and asking questions about code that you are writing specifically. Unless someone here is willing to just say, "go with this one."
[eluser]Nick_MyShuitings[/eluser]
There really are too ways you can work it. I'll bring up the file structure since the reference bretticus sent (I have implemented in my toolbox stack) deals more with db. if you check over the file structure of index.php of the application folder, you'll quickly realize that you can move it wherever you want in relation to the system folder and even the rest of the application folder (although I prefer to keep it inside the application folder for obvious organizational reasons). You will also see that system is in no way dependent on application, and thus can support infinite applications. My personal preference is the following: system webroot -application1 --index.php -application2 --index.php Where system is not even web accessible and multiple application folders are running off the same core system and contrib libraries.
[eluser]smilie[/eluser]
I have similar approach: /ci_core /app1 --application --www (apache's root) /app2 --application --www (apache's root) /app3 --application --www (apache's root) ... So, this way all applications use one ci_core, but all have each own application and www (root) folders. Just in app1/www -> index.php tell it where can it find ci_core and application folder and that's it. Regards, Smilie
[eluser]Nick_MyShuitings[/eluser]
I think I like that even more... it gets you application folder out of the web accesible location. Big Plus!
[eluser]bretticus[/eluser]
Hi @dan.tdr, To chime in, I agree that if you have a finite amount of subdomains (2-10 let's say) multiple application folders make sense (also, putting the apache roots outside of the application is a good security idea any day.) However, if your subdomains are infinite (you said you knew about DNS wildcards so I assumed you might have infinite subdomains) a single application approach similar to Phil's post is the best. Yes, it does focus on different databases for different subdomains, but it also shows how you can set your base_url dynamically (which you would need to do with infinite subdomains) and the switch statement isn't a bad idea to set a global constant that dictates which subdomain is being referenced. Not the whole picture, but some good ideas to base your application on. I was hoping to inspire you to ask more specific questions about this. Many of us here have done this before. You asked for an example, but there are so many. And you, yourself, admitted you had looked at them all. So, if you're still reading this post, tell us what you are trying to accomplish at least if you haven't got it figured yet. Really, I like to answer questions here. I just have a hard time with, "show me the code!" requests. |
Welcome Guest, Not a member yet? Register Sign In |