I ended up with a function looking like this. It uses the document root for the current server, but then strips away the part before directory name of the website root - which is really the directory name of the directory name one step above were this function is located:
$dirName = dirname(dirname(__FILE__) . ".." . DIRECTORY_SEPARATOR);
$dirName = str_replace('\\', "/", $dirName);
$base = str_replace($_SERVER['DOCUMENT_ROOT'], "", $dirName);
With a document root of /etc/webserver/documents/
and a website under /projects/website1
in your document root it would return /projects/website1
if this script is located in /projects/website1/somreDir/someFile.php
.
Hopes this helps someone.