Fix redirect to detect correct host