$_SERVER['PHP_SELF']; è tutto quello che segue il dominio, e con $_SERVER['HTTP_HOST']; dovresti ottenere il dominio