0

How to redirect https://hr.test.in/old-test-contact to https://www.test.in/info/contactus ?

I tried the following rule but it does not work.

 <rule name="new rule" patternSyntax="Wildcard" stopProcessing="true">
              <match url="*" />
              <conditions>
                <add input="{HTTP_HOST}" matchType="Pattern" pattern="hr.test.in" />
              </conditions>
              <action type="Redirect" url="https://www.test.in/info/{R:0}" />
            </rule>

When I use the above rule I am redirected to https://www.test.in/info/old-test-contact.

However the below redirect works fine with above rule.

https://hr.test.in/vacancies to https://www.test.in/info/vacancies

Any ideas how I can get https://hr.test.in/old-test-contact to https://www.test.in/info/contactus working?

Debasish
  • 417
  • 1
  • 10
  • 21
  • Does this answer your question? [How to redirect a URL path in IIS?](https://stackoverflow.com/questions/888325/how-to-redirect-a-url-path-in-iis) – gunr2171 Mar 26 '21 at 14:44
  • 1
    `old-test-contact` is captured into R:0 - perhaps instead you should add a condition to check if the path is `old-test-contact` and redirect to /contactus, no capturing required – Caius Jard Mar 26 '21 at 14:48

1 Answers1

0

According to your matching rules, {R:0} at this time should be old-test-contact, You can use the Test Pattern in IIS to view the value of {R:0}:

enter image description here

You can try to use this URL Rewrite Rule:

       <rule name="new rule" patternSyntax="Wildcard" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="hr.test.in" />
          </conditions>
          <action type="Redirect" url="https://www.test.in/info/contactus" />
        </rule>
Ding Peng
  • 3,702
  • 1
  • 5
  • 8