Page 1 of 1

sharing code across subdomains

Posted: Sat Sep 25, 2004 11:50 pm
by nasium
i am working on a project that is considering using subdomains.

I would prefer to use one PHP code base, not copying the code into each subdomain. When a user hits a particular subdomain, i want use the SD name to pull particular data purtaining to the SD from the db.

Do i need to deploy individual PHP code bases to each subdomain or can they all share the same code?

thanx

Posted: Sun Sep 26, 2004 12:36 am
by feyd
it kinda depends on how the subdomains work for your particular server/application. If the subdomains automatically are folders under your main document root, then you can use mod_rewrite to alter the requested url into something "universal" for the site, or you can place a small starter script in these directories that includes proper folder's contents, or, you could potentially, alias these folders at a common folder to load data from.

Posted: Sun Sep 26, 2004 8:22 am
by McGruff
You can use the same code libraries very easily. Store them off root somewhere and either edit the php.ini includes_path or define a constant which leads to the library folder.

Different sub-domains ought to have their own databases: each sub domain would have its own db connection config file (again off-root, this time for security reasons) where you can specify what to connect to.

Miscellaneous other bits and pieces will need to be added per sub domain: at least some (if not all) of the html (or etc) templates, CSS, messages, and so on. And all the http invoke-able scripts, of course.