more robust handling of redirects for localhost portmapped urls