Redirect to the correct page on error