Encode/decode the redirect URL to be returned to the correct page when a query string is present.