updated database.php file to handle self redirects