Welcome Guest, Not a member yet? Register   Sign In
[updated] Web App Architechture Question
#1

[eluser]Neeraj Kumar[/eluser]
Hi all!

You all must have seen how 37Signals creates new subdomain for their clients through web.

I am developing a new CI app. I want to know how to implement the same. How to create new subdomain on the fly each time a new client register for my product. Do I need to install a new copy of app to each subdomain, do I need to install a new DB, I mean I really know nothing about this thing.

Any Ideas, Please help me on this.
#2

[eluser]guillermo, out of repose[/eluser]
You can do it with one database and one installation of codeigniter. There're a few different ways you can go about implementing something like that, depending on what kind of server you're using. Folks here would probably need more details (and, quite honestly, maybe some money lol) to provide more insight.
#3

[eluser]Neeraj Kumar[/eluser]
money part was great lol!

anyways, some insights!!

I am and will be using LAMP stack. cPanel will be my WHM. I'll have a URL like www.abc.com when ever a user come and register his sompany with me, I'll be creating a new subdomain on th fly using an online registration form like person.abc.com

Then that person will be able to access his area by person.abc.com/login.

http://basecamphq.com/ is the best example of what I want to do. Only thing is I'll be using CodeIgniter instead of RoR.

hope that helps! cheers!
#4

[eluser]ggoforth[/eluser]
I am doing something similar right now using .htaccess to rewrite the domain. In my case when a user goes to:

http://username.site.com

This is rewritten to:

http://app.site.com/controller/method/username

Where the username is now a variable passed to a controller. You will need to have mod rewrite for apache set up and configured. A few lines in an .htaccess file should help you accomplish what your looking for. You will also have to have a wildcard subdomain set up for this to work.

Greg
#5

[eluser]guillermo, out of repose[/eluser]
ggoforth is dead on... here's a good post about how to get the Apache stuff done: http://www.webmasterworld.com/forum92/368.htm

The rest is cake.
#6

[eluser]Neeraj Kumar[/eluser]
ok so should I just now concentrate on creating the app part as if there would be no subdomain thing involved and later I can do it via .htaccess?

Is there any other method, may be creating real sub domains? which is the best method?

I personally think that htaccess part is good but I kinda find it to be something like fooling web server. and will this not create DB overload problems as data will increase later on?

also ggforth, could you put some more light on your process like .htaccess code and something on wildcard domains. htaccess is ok I can do that but wildcards domains is waht i am hearing for the first time Smile
#7

[eluser]ggoforth[/eluser]
From my .htaccess file:

Code:
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).mydomain.com$
RewriteRule ^(.*)$ http://app.mydomain.com/controller/method/%1 [L]

This will match any subdomain and rewrite it using back references to the URL found in the RewriteRule. Note, if you are using any other subdomain that you do not want rewritten, you need to tell your htaccess file to skip them using something like:

Code:
RewriteCond %{HTTP_HOST} !^images.mydomain.com$
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).mydomain.com$
RewriteRule ^(.*)$ http://app.mydomain.com/controller/method/%1 [L]

In the above example the images subdomain would not be rewritten.

Wildcard subdomains are what makes any of this possible. Because the subdomains won't actually exist, without a wildcard you would just get 404 errors (or some other http error). A Wildcard domain will accept anything then your .htaccess file has to do the job of rewriting to the proper URL. Here is a good tutorial Wildcard Subdomains. Note, it does require you have access to your httpd.conf, etc...
#8

[eluser]bretticus[/eluser]
Pardon my thread hijacking...

Nice ggoforth! When I read this, I was wondering how to do a sub expression match from a RewriteCond. In the past, I have actually dedicated a host ip to specifically handle the sub domain hits (ouch!) Nice to see that this can be done from a VirtualHost directive.

Just curious, could you not just write the RewriteRule as:

RewriteRule ^(.*)$ index.php?/controller/method/%1 [L]

Provide that you set *.domain.tld as a ServerAlias?

Thanks! Cool Stuff.
#9

[eluser]Neeraj Kumar[/eluser]
ohh man, thanks for the help. I'll check it out
#10

[eluser]Neeraj Kumar[/eluser]
one more thing, I am planning to use logs also.

Also there is going to be lots of data in DB, do you guys think that keeping only one copy of DB will do in terms of DB load? I am talking about thousands of records if not millions.


----

Added:

One more thing, What do you guys use for DB access? Datamapper or active record.

I want to use an ORM? which is the best orm for CodeIgniter that can handle heavy databases? I tried Doctrine but had no luck.




Theme © iAndrew 2016 - Forum software by © MyBB