I have an IIS site with rewrite URLs to hide the port from our API users (not my choice). In other words, the main side rewrites urls to diffent sites on the same machine.
So if I visit (port 11001 is just for testing, it will eventually be on port 80):
http://apitest.mycompany.com:11001/v1/accounts
http://apitest.mycompany.com:11001/v1/swagger/docs/accounts
I want the rewrite to return the result from (respectively):
http://apitest.mycompany.com:9600/v1/accounts
http://apitest.mycompany.com:9600/v1/swagger/docs/accounts
There is only one rewrite rule in play here, yet while the second URL is rewritten and returned correctly, the first on yields a 404 error.
I can visit both the rewritten links directly and they will work. I can also make a temporary redirect based on the exact same rule which works.
My rewrite rule looks like this:
Match
- regex, ignore case: .*/accounts.*
Action
- Rewrite
- URL: 'http://apitest.mycompany.com:9600/{R:0}'
- Append query string: true
- Stop processing of subsequent rules: true
I've been looking at the failed rewrite log file, but I can't see what the problem is: