0
votes

I have the following IIS URL Rewrite Rule. If a request is of the form

/PatientListAppSSO/index.html

the request is redirected else if the request is of the form

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

the request is handled.

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

The Rewrite Rule does not redirect when a request is made with no query string. I see the following in the Failed Request Logs:

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

The ExpandedInput field indicates a zero-length query string is being matched against ^$ which should result in a positive match, but the Succeeded field states false.

Any ideas where I am going wrong?

1

1 Answers

1
votes

You could use below URL rewrite rule:

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

which redirect if url is:

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

enter image description here

and

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

enter image description here