Handle redirects correctly