使用获取参数的 Azure 服务器重定向模块

Azure Server Redirect module using get parameters

我尝试使用使用此模式的重写模块在 Azure 网站上进行永久重定向:

   <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 参数

通过示例重定向:

例子.com/product/Product.aspx?product_id=287

例子.com/product/Product.aspx?product_id=35

示例。com/product

但不是整个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>

以上规则将重定向:

例子.com/product/Product.aspx?product_id=287

例子.com/product/Product.aspx?product_id=35

示例。com/product