【问题标题】:URL Rewrite IIS 7.5 "?" character int the request urlURL 重写 IIS 7.5 “?”请求 url 中的字符
【发布时间】:2013-11-07 12:33:21
【问题描述】:

我有一个传入的请求 URL:

http://localhost/MyService/myservice.svc?serverInfo&pVersion=00

我在 webconfig 中写了一条规则(在 IIS 管理器中使用 URL 重写):

<rule name="ServerInfo" stopProcessing="true">
                    <match url="myservice[.]svc[\?]serverInfo[&amp;]pVersion[=]([^]+)" />
                    <action type="Redirect" url="myservice.svc/folder/serverInfo/pVersion={R:1}" />
                </rule>

但它不起作用,因为我在匹配网址中使用了 "?" 字符。

我应该如何更改正则表达式才能正常工作?

(我必须进行重定向/重写,因为它是一个安静的 WCF 服务,并且它不支持传入 url 的类型)

【问题讨论】:

    标签: regex wcf iis-7 url-rewriting web-config


    【解决方案1】:

    改为这样做:

    <rule name="ServerInfo" stopProcessing="true">
      <match url="myservice.svc" ignoreCase="true" />
    
      <conditions logicalGrouping="MatchAll">
        <add input="{QUERY_STRING}" pattern="serverInfo&amp;pVersion=([^]+)" />
      </conditions>
    
      <action type="Redirect" 
              url="myservice.svc/folder/serverInfo/pVersion={C:1}" 
              appendQueryString="false" 
              redirectType="Found" />
    </rule>
    

    【讨论】:

      猜你喜欢
      • 2013-06-01
      • 2013-01-06
      • 2012-05-23
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      • 2012-02-28
      • 2011-10-21
      • 1970-01-01
      相关资源
      最近更新 更多