Generate correct redirect