I'm trying to add a iis url rewrite rule in web.config. The rule should be as follows.
If the url does not contain www, then redirect to www However, if the Host contains, 'svha-prd-as-careservices-01' then do not redirect to www
Below is my code, the www redirect is working however, negate condition to check 'svha-prd-as-careservices-01' is not working. What am I missing?
<rule name="Redirect Non-WWW to WWW" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)" />
<add input="{REQUEST_HOST}" pattern="^(.*)svha-prd-as-careservices-01(.*)" negate="true" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />