Fix panic caused by redirection