简体   繁体   English

IIS7重定向模式

[英]IIS7 Redirect pattern

Using IIS7 with rewrite module to create a redirect 使用带有重写模块的IIS7创建重定向

Source request URL: http://www.domain.com/term/code.html?Product=55824 Should redirect to http://www.domain.com/product/55824 源请求URL: http : //www.domain.com/term/code.html? Product = 55824应该重定向到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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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