Fix `handleRedirects` to properly escape URLs in HTML