简体   繁体   中英

IIS redirect URL

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?

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}:

在此处输入图像描述

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM