The line: $host = $_SERVER['HTTP_HOST']; I believe needs to be changed to: $host = $_SERVER['SERVER_NAME']; HTTP_HOST may contain a port number which will cause the returning the URL to have the port number doubled up. Bob