Refactoring codes to use domain redirect feature