Reconstruct redirect URL based on hostname rather than localhost