Azure的服务器重定向使用模块GET参数
问题描述:
我尝试使用重写模块使用这种模式,使上一个蓝色的网站上永久重定向:Azure的服务器重定向使用模块GET参数
<rule name="Rewrite redirect-not-found-products-w" patternSyntax="ExactMatch" stopProcessing="true">
<match url="product/Product.aspx?product_id=287"/>
<action type="Redirect" url="https://example.com/product" redirectType="Permanent"/>
</rule>
不过,我想利用GET参数保健
通过例如重定向:
example.com/product/Product.aspx?product_id=287
或
example.com/product/Product.aspx?product_id=35
到
example.com/product
而不是整个产品/ Product.aspx
答
您的规则应该具有查询字符串的条件,您不能在match url=
<rule name="Rewrite redirect-not-found-products-w" stopProcessing="true">
<match url="^product/Product.aspx$" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="^product_id=287$" />
<add input="{QUERY_STRING}" pattern="^product_id=35$" />
</conditions>
<action type="Redirect" url="https://example.com/product" redirectType="Permanent" />
</rule>
规则将重定向:
example.com/product/Product.aspx?product_id=287
或
example.com/product/Product.aspx?product_id=35
到
example.com/product