简体   繁体   中英

IIS7 Redirect pattern

Using IIS7 with rewrite module to create a redirect

Source request URL: http://www.domain.com/term/code.html?Product=55824 Should redirect to http://www.domain.com/product/55824

Current Rule (does not work)

<rule name="PatternRedirect" stopProcessing="true">
          <match url="term/([a-z]+)(.*)Product=([0-9]+)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="www.domain.com$" />
          </conditions>
          <action type="Redirect" url="http://www.domain.com/product/{R:3}"
            redirectType="Permanent" />
</rule>

Any ideas why the above isnt working?

Thanks

Query string is not included in main match string, you have to use Conditions to evaluate it.

<rule name="PatternRedirect" stopProcessing="true">
          <match url="^term/.*" />
          <conditions  trackAllCaptures="true">
            <add input="{QUERY_STRING}" pattern="Product=([0-9]+)" />         
            <add input="{HTTP_HOST}" pattern="^www.domain.com$" />
          </conditions>
          <action type="Redirect" url="http://www.domain.com/product/{C:1}"
            redirectType="Permanent" />
</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