0
votes

I am not able to get IIS Url Rewrite to work on IIS 7.5

I installed the latest IIS URL Rewrite Module from http://www.iis.net/downloads/microsoft/url-rewrite

Now the following rule is working

<rule name="TestRewrite" stopProcessing="true">
                    <match url="abc\/(.*)" />
                    <action type="Rewrite" url="test/{R:1}" logRewrittenUrl="true" />
                </rule> 

However this rule is not

<rule name="TestRewrite" stopProcessing="true">
                    <match url="abc\/(.*)" />
                    <action type="Rewrite" url="http://localhost:8082/{R:1}" logRewrittenUrl="true" />
                </rule>

Trace result

<table class=3DMsoNormalTable border=3D1 cellspacing=3D0 cellpadding=3D0 wi=d th=3D "112%" style=3D 'width:112.1%;border-collapse:collapse;mso-yfti-tbllook:1184;mso-p=
adding-alt:
 0in 0in 0in 0in'>
  <tr style=3D 'mso-yfti-irow:0;mso-yfti-firstrow:yes'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;background:#E9EEF2;pa=
dding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-top:6.0pt;margin-right:0in;margin-bo=
ttom:
  18.75pt;margin-left:0in;line-height:normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","serif";mso-farea=
st-font-family:
  "Times New Roman";color:black'>URL_REWRITE_START<o:p></o:p></span>
      </p>
    </td>
    <td width=3D "57%" valign=3Dtop style=3D 'width:57.76%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span class=3DSpellE><span style=3D'font-size:12.0pt;font-family:"Verdana","san=
s-serif";
  mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Courier N=
ew";
  color:black'>RequestURL</span></span><span style=3D 'font-size:12.0pt;
  font-family:"Verdana","sans-serif";mso-fareast-font-family:"Times New Rom=
an";
  mso-bidi-font-family:"Courier New";color:black'>=3D&quot;/<span class=3DS=
pellE>abc</span>/index.html&quot;, Scope=3D&quot;Distributed&quot;, Type=3D&quot;Inbound&quot;
        <o:p></o:p>
        </s=p an>
      </p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman";color:black'>22:46:22.772<o:p><=
/o:p></span>
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:1'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;padding:.75pt 15.0pt =
.75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman"'>RULE_EVALUATION_START<o:p></o:=
p></span>
      </p>
    </td>
    <td width=3D "57%" valign=3Dtop style=3D 'width:57.76%;padding:.75pt 15.0pt=
 .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span class=3DSpellE><span style=3D'font-size:12.0pt;font-family:"Verdana","san=
s-serif";
  mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Courier N=
ew"'>RuleName</span></span><span style=3D 'font-size:12.0pt;font-family:"Verdana","sans-serif";mso-fareast-=
font-family:
  "Times New Roman";mso-bidi-font-family:"Courier New"'>=3D&quot;<span
  class=3DSpellE>TestRewrite</span>&quot;, <span class=3DSpellE>RequestURL<=
/span>=3D&quot;<span
  class=3DSpellE>abc</span>/index.html&quot;, <span class=3DSpellE>QueryStr=
ing</span>=3D&quot;&quot;,
        <span class=3DSpellE>PatternSyntax</span>=3D&quot;Regex&quot;, <span class=3DSpellE>StopProcessing</span>=3D&quot;true&quot;, <span class=3DSp=e llE>RelativePath</span>=3D&quot;/&quot;
        <o:p></o:p>
        </span>
      </p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;padding:.75pt 15.0pt=
 .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman"'>22:46:22.772<o:p></o:p></span>=
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:2'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;background:#E9EEF2;pa=
dding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman";color:black'>PATTERN_MATCH<o:p>=
</o:p></span>
      </p>
    </td>
    <td width=3D "57%" valign=3Dtop style=3D 'width:57.76%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span style=3D 'font-size:12.0pt;font-family:"Verdana","sans-serif";mso-fareast-=
font-family:
  "Times New Roman";mso-bidi-font-family:"Courier New";color:black'>Pattern=
=3D&quot;<span
  class=3DSpellE>abc</span>\/(.*)&quot;, Input=3D&quot;<span class=3DSpellE=>abc</span>/index.html&quot;, Negate=3D&quot;false&quot;, Matched=3D&quot;true&quot;
        <o:p></o:p>
        </span>
        <=/ p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman";color:black'>22:46:22.772<o:p><=
/o:p></span>
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:3'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;padding:.75pt 15.0pt =
.75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman"'>REWRITE_ACTION<o:p></o:p></spa=
n></p>
  </td>
  <td width=3D"57%" valign=3Dtop style=3D'width:57.76%;padding:.75pt 15.0pt=
 .75pt .75pt'>
  <p class=3DMsoNormal style=3D'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
  style=3D'font-size:12.0pt;font-family:"Verdana","sans-serif";mso-fareast-=
font-family:
  "Times New Roman";mso-bidi-font-family:"Courier New"'>Substitution=3D&quo=
t;http://localhost:8082/{R:1}&quot;,
  <span class=3DSpellE>RewriteURL</span>=3D&quot;http://localhost:8082/inde= x.html&quot;,
        <span class=3DSpellE>AppendQueryString</span>=3D&quot;true&quot;, <span class=3DSpellE>LogRewrittenURL</span>=3D&quot;true&quot;
        <o:p></o:p>
        </span=>
      </p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;padding:.75pt 15.0pt=
 .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman"'>22:46:22.772<o:p></o:p></span>=
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:4'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;background:#E9EEF2;pa=
dding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman";color:black'>RULE_EVALUATION_EN=
D<o:p></o:p></span>
      </p>
    </td>
    <td width=3D "57%" valign=3Dtop style=3D 'width:57.76%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span class=3DSpellE><span style=3D'font-size:12.0pt;font-family:"Verdana","san=
s-serif";
  mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Courier N=
ew";
  color:black'>RuleName</span></span><span style=3D 'font-size:12.0pt;font-f=
amily:
  "Verdana","sans-serif";mso-fareast-font-family:"Times New Roman";mso-bidi=
-font-family:
  "Courier New";color:black'>=3D&quot;<span class=3DSpellE>TestRewrite</spa=
n>&quot;,
  <span class=3DSpellE>RequestURL</span>=3D&quot;http://localhost:8082/inde= x.html&quot;,
        <span class=3DSpellE>QueryString</span>=3D&quot;&quot;, <span class=3DSpe=l lE>StopProcessing</span>=3D&quot;true&quot;, Succeeded=3D&quot;true&quot;
        <o:p></o:p>
        </span>
      </p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman";color:black'>22:46:22.772<o:p><=
/o:p></span>
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:5'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;padding:.75pt 15.0pt =
.75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman"'>GENERAL_SET_REQUEST_HEADER<o:p=
></o:p></span>
      </p>
    </td>
    <td width=3D "57%" valign=3Dtop style=3D 'width:57.76%;padding:.75pt 15.0pt=
 .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span class=3DSpellE><span style=3D'font-size:12.0pt;font-family:"Verdana","san=
s-serif";
  mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Courier N=
ew"'>HeaderName</span></span><span style=3D 'font-size:12.0pt;font-family:"Verdana","sans-serif";mso-fareast-=
font-family:
  "Times New Roman";mso-bidi-font-family:"Courier New"'>=3D&quot;X-Original=
-URL&quot;,
  <span class=3DSpellE>HeaderValue</span>=3D&quot;/<span class=3DSpellE>abc=
</span>/index.html&quot;, Replace=3D&quot;true&quot;
        <o:p></o:p>
        </span>
      </p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;padding:.75pt 15.0pt=
 .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman"'>22:46:22.772<o:p></o:p></span>=
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:6'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;background:#E9EEF2;pa=
dding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman";color:black'>URL_CHANGED<o:p></=
o:p></span>
      </p>
    </td>
    <td width=3D "57%" valign=3Dtop style=3D 'width:57.76%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span class=3DSpellE><span style=3D'font-size:12.0pt;font-family:"Verdana","san=
s-serif";
  mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Courier N=
ew";
  color:black'>OldUrl</span></span><span style=3D 'font-size:12.0pt;font-fam=
ily:
  "Verdana","sans-serif";mso-fareast-font-family:"Times New Roman";mso-bidi=
-font-family:
  "Courier New";color:black'>=3D&quot;/<span class=3DSpellE>abc</span>/inde= x.html&quot;,
        <span class=3DSpellE>NewUrl</span>=3D&quot;http://localhost:8082/index.ht= ml&quot;
        <o:p></o:p>
        </span>
      </p>
    </td>
    <td width=3D "14%" valign=3Dtop style=3D 'width:14.66%;background:#E9EEF2;p=
adding:
  .75pt 15.0pt .75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal'><span style=3D 'font-size:12.0pt;font-family:"Times New Roman","se=
rif";
  mso-fareast-font-family:"Times New Roman";color:black'>22:46:22.772<o:p><=
/o:p></span>
      </p>
    </td>
  </tr>
  <tr style=3D 'mso-yfti-irow:7;mso-yfti-lastrow:yes'>
    <td width=3D "27%" valign=3Dtop style=3D 'width:27.6%;padding:.75pt 15.0pt =
.75pt .75pt'>
      <p class=3DMsoNormal style=3D 'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;word-break:break-all'><span style=3D 'font-size:12.0pt;font-family:=
"Times New Roman","serif";
  mso-fareast-font-family:"Times New Roman"'>URL_REWRITE_END<o:p></o:p></sp=
an></p>
  </td>
  <td width=3D"57%" valign=3Dtop style=3D'width:57.76%;padding:.75pt 15.0pt=
 .75pt .75pt'>
  <p class=3DMsoNormal style=3D'margin-bottom:0in;margin-bottom:.0001pt;lin=
e-height:
  normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 36=
6.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
  class=3DSpellE><span style=3D'font-size:12.0pt;font-family:"Verdana","san=
s-serif";
  mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Courier N=
ew"'>RequestURL</span></span><span style=3D 'font-size:12.0pt;font-family:"Verdana","sans-serif";mso-fareast-=
font-family:
  "Times New Roman";mso-bidi-font-family:"Courier New"'>=3D&quot;http://loc=
alhost:8082/index.html&quot;<o:p></o:p></span>
      </p>
    </td>
    <td width=3D "14%" style=3D 'width:14.66%;border-top:none;border-left:none;
  border-bottom:inset 1.0pt;border-right:inset 1.0pt;mso-border-bottom-alt:
  inset windowtext .75pt;mso-border-right-alt:inset windowtext .75pt;
  padding:0in 0in 0in 0in'></td>
  </tr>
</table>
1
What URL are you testing this rule with? - Josh
I got the solution for this...ARR was not configured properly - fitnet

1 Answers

0
votes

You may want to double check your regex for what you were expecting. That expression won't match localhost because abc is not at the beginning. This would match your URL:

abc\/(.*)

Notice we are looking for abc anywhere and the escaping the slash and we can end with anything.