refactor handle_301_redirects