Grazie ho risolto con $_SERVER['REQUEST_URI'].