【问题标题】:IIS URL Rewrite Inbound Rule Condition FailsIIS URL 重写入站规则条件失败
【发布时间】:2019-09-09 16:20:57
【问题描述】:

我有以下 IIS URL 重写规则。如果请求的格式为

/PatientListAppSSO/index.html

如果请求的格式为

,则请求被重定向,否则

/PatientListAppSSO/index.html?data=stuff....

请求已处理。

       <rule name="PLA Rewrite Rule" patternSyntax="ExactMatch" stopProcessing="true">
            <match url="index.html" />
            <action type="Redirect" url="../PatientListApp/default.aspx" appendQueryString="false" logRewrittenUrl="true" redirectType="Found" />
            <conditions>
                <add input="{QUERY_STRING}" pattern="^$" />
            </conditions>
        </rule>

在没有查询字符串的情况下发出请求时,重写规则不会重定向。 我在失败的请求日志中看到以下内容:

 <EventData>
  <Data Name="ContextId">{80000002-0001-F800-B63F-84710C7967BB}</Data>
  <Data Name="Input">{QUERY_STRING}</Data>
  <Data Name="ExpandedInput"></Data>
  <Data Name="MatchType">0</Data>
  <Data Name="Pattern">^$</Data>
  <Data Name="Negate">false</Data>
  <Data Name="Succeeded">false</Data>
 </EventData>

ExpandedInput 字段表示一个零长度的查询字符串正在与 ^$ 进行匹配,这应该会导致正匹配,但 Succeeded 字段状态为 false。

任何想法我哪里出错了?

【问题讨论】:

    标签: iis url-rewriting


    【解决方案1】:

    您可以使用以下 URL 重写规则:

    <rule name="PLA Rewrite Rule" patternSyntax="ECMAScript" stopProcessing="true">
         <match url="(.*)" />
         <action type="Redirect" url="/PatientListApp/default.aspx" appendQueryString="false" logRewrittenUrl="true" redirectType="Found" />
         <conditions>
                        <add input="{REQUEST_URI}" pattern="/index.html" />
         </conditions>
       </rule>
    

    如果 url 是哪个重定向:

    http://www.sample1.com/index.html?id=123

    http://www.sample1.com/index.html

    【讨论】:

    • 非常感谢!您的回答建议的答案是我选择 ExactMatch for patternSyntax 不知道它也适用于条件!我将其更改为 RegExp,现在它可以工作了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-15
    • 2014-10-27
    • 1970-01-01
    • 2014-05-01
    相关资源
    最近更新 更多