improve redirect url detection