Nice find. CR98328 was an issue in 9.4.x and fixed in 10.0.0 per SOL8676. Which LTM version are you testing this on?
SOL8676: The HTTP::header values iRule command removes colon characters from header values
https://support.f5.com/kb/en-us/solutions/public/8000/600/sol8676.html
If that is the problem, you could try removing the colons in the iRule as well. It wouldn't be pretty but it should work.
[HTTP::header Location] contains "www.acme.com:10040" -> [HTTP::header Location] contains "www.acme.com10040"
...
string map -nocase {www.acme.com:10400 www.acme.com} -> string map -nocase {www.acme.com10400 www.acme.com}
Aaron