1
votes

I would like to match exactly https://internet.dev.local/KYR url (without / into end) and redirect or rewrite to https://internet.dev.local/KYR/ (with /).

I am trying the following rule but it matches other URLs as well e.g. https://internet.dev.local/KYR/Admin/Form/Default.aspx?signup=false, which is wrong.

so how can I achieve this?

<rule name="Static redirect" patternSyntax="ExactMatch" stopProcessing="true">
        <match url="https://internet.dev.local/KYR" negate="true" />
        <conditions>
        </conditions>
        <action type="Redirect" url="/Login/?ReturnUrl=/Member/KYR/" redirectType="Permanent" />
      </rule>
1

1 Answers

0
votes

If you need to test the host and protocol you have to put it in the conditions, not in the global rule.
Following your example, it would be as follow:

<rule name="test" patternSyntax="ExactMatch" stopProcessing="true">
  <match url="KYR" />
  <action type="Redirect" url="/KYR/" redirectType="Permanent" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="internet.dev.local" />
    <add input="{HTTPS}" pattern="on" />
  </conditions>
</rule>

I have changed the url in the action because your question says:
redirect or rewrite to https://internet.dev.local/KYR/ (with /).

EDIT:
To get it to work on any host (with or without SSL), just remove the conditions:

<rule name="test" patternSyntax="ExactMatch" stopProcessing="true">
  <match url="KYR" />
  <action type="Redirect" url="/KYR/" redirectType="Permanent" />
</rule>