I'm trying to configure a rule in UrlRewrite that has 2 conditions:
- HTTP header
HTTP_HOST
needs to match a certain domain (api.contoso.com) - A custom HTTP header
x-app-version
needs to be present in the HTTP request
based on this info, I'd like to redirect to a different version of the API in the back-end.
Problem
The rule is behaving as expected on the first condition.
It kicks in when HTTP_HOST
matches api.contoso.com.
However, it ignores my custom x-app-version
header.
Assumption
So, I fear that a UrlRewrite condition only can be defined in combination with the limited set of predefined HTTP headers from the dropdown (HTTP_HOST
, REMOTE_ADDRESS
, REMOTE_HOST
, …)
Question Is assumption correct or should this be possible whatsoever? Is there a mistake in my config or other approach to have conditions based on a custom defined HTTP header?
<rule name="ARR_test2" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="api.contoso.com" />
<add input="{x-app-version}" pattern="1" />
</conditions>
<action type="Rewrite" url="https://FARM_apiv1/{R:0}" />
</rule>