When setting up a server to use with CDN origin I have noticed that when you request a path without a slash (www.mydomain.com/app) the courtesy 301 kicks in which causes some problems as the user is then redirected to the origin domain rather than the pretty public domain.
This issue is that it attempts to perform a redirect based on the origin domain (hidden from the public) rather than the public facing domain.
I'm trying to write a rule that looks for 30x response codes, if matches then change the domain name in the location whilst preserving the path.
I've got the basis on how to check to first check for the response codes but I'm unsure how to achieve replacing the domain with the correct one in the location.