sharing code across subdomains

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
nasium
Forum Newbie
Posts: 1
Joined: Sat Sep 25, 2004 11:43 pm

sharing code across subdomains

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Post Reply