Fix the redirect in case of multiple databases and if the failing database is not the first. re #116