Use JS to handle redirects