【问题标题】:IIS Rewrite Module to map querystringsIIS 重写模块以映射查询字符串
【发布时间】:2012-11-20 08:05:14
【问题描述】:

我在 IIS7.5 上使用 IIS 重写模块。我的映射位于结构中的文本文件中:

[old url], [new url]

所以这样的事情是有效的:

products/abc, http://test.com/new/products/abc

这在我的 web.config 中使用以下规则

 <rule name="FileMapProviderRule" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{FileMapProvider:{R:1}}" pattern="(.+)" />
      </conditions>
      <action type="Redirect" url="{C:1}" redirectType="Permanent" />
 </rule>

如果我也想传递查询字符串,我的规则是什么?所以我想让这个工作:

products?sku=123, http://test.com/new/products/123
products?sku=789, http://test.com/new/products/789

【问题讨论】:

    标签: iis-7.5 url-rewrite-module


    【解决方案1】:

    我通过以下规则解决了这个问题:

    <rule name="Products" patternSyntax="Wildcard" stopProcessing="true">
        <match url="products" />
        <conditions>
            <add input="{QUERY_STRING}" pattern="sku=*" />
        </conditions>
        <action type="Redirect" url="http://test.com/new/products/{C:1}" appendQueryString="false" redirectType="Permanent" />
    </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      • 2020-03-14
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多