I have url like this http://example.com/dir1/dir2/dir3/dir4/Page.php?charts.htm and I need to remove the page/extension before the querystring so it outputs http://example.com/dir1/dir2/dir3/dir4/?charts.htm
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$temp = explode( '?' , $url );
$temp[0] = ""; //remove part before the ?
Not even sure if I'm on the right track here