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
sharing code across subdomains
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.
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.
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.