Ti dovrebbe bastare utilizzare HTTP_HOST e PHP_SELF:

Codice PHP:
$base $_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF'];