An idea would be to take something like this:
and either explode it based on a particular number of psuedo-directories after the PHP script.
Example (I can't remember the actual function to make this happen in PHP, however):
//chop the $inputstring into an array delimited by "/"
//reminds me of a CSV file
$inputstring = "/test.php/somepath/var1/var2/index.htm";
$path = $inputstring;
$var1 = $inputstring;
//and so on