SubDomains and PHP

I searched existing threads, but didn’t find anything; apologies if this is a repeat.

I am currently porting software that was developed in-house on a single machine to be more “pluggable.”

To acheive that goal, I had the bright idea to do it using subdomains. This would make it easier for me to manage in that I could use “package.DEV.COMPANY.COM” instead of a new account for each. The problem is, that the PHP is using a particular method to reduce hard-coded links:

include($_SERVER["DOCUMENT_ROOT"] . "/lib/" . "appsetup.php");

That looks like it’s a perfect solution, and precisely what I want to do (e.g. instead of having hard-coded, tied-to-one-server paths). The problem is that a subdomain has the following DOCUMENT_ROOT:


when it should be


Everything is made to work problem from the Apache side using rewrite rules, but the PHP variable is never “fixed” to reflect the correct DOCUMENT_ROOT.

Can anyone come up with a work-around? or am I instead wating on the multi-domain capability of v3?

Could try this untested:

$include = str_replace($_SERVER['SCRIPT_NAME'], "/lib/appsetup.php", $_SERVER['PATH_TRANSLATED']);

I would use SCRIPT_NAME instead of anything else, as if you pass GET values to the line the str_replace function wont work properly.