SCRIPT_URI? I've never seen that used in PHP...
(Edit: Apparently it only exists under Apache with mod_rewrite enabled)
Anyway, the easiest way to remove the filename is to use the dirname() function...
code:
if(empty($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
}
// Strip off query string so dirname() doesn't get confused
$url = preg_replace('/\?.*$/', '', $_SERVER['REQUEST_URI']);
$url = 'http://'.$_SERVER['HTTP_HOST'].'/'.ltrim(dirname($url), '/').'/';
http://shoutbox.menthix.net/crap/asdf/uri_test.php