You can use the 'REQUEST_URI' server variable.
For example in the URL
http://www.somewhere.com/index.php/bob/red.png
$_SERVER['REQUEST_URI'] would be /index.php/bob/red.png
And this code should get just the /bob/red.png at the end.
code:
<?php
$filename = "index.php";
$request = strstr($_SERVER['REQUEST_URI'],$filename);
$request = strstr($request,"/");
?>
See this implementation
http://www.baxteronline.com/uriviewer.php/this/is/a/test