Jason
Jason

Reputation: 85

Problems with Regular Expression for Rewrite

I'm having problems with my regular expression, can someone help?

Example URL: http://rhine.ga.domain.com

<rule name="CityStateRule">
    <match url="^.*(/$|$)"/>
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(^[A-Za-z0-9_-]+)\.(^(?:a[klrz]|c[aot]|d[ce]|fl|ga|hi|i[adln]|k[sy]|la|m[adeinost]|n[cdehjmvy]|o[hkr]|pa|ri|s[cd]|t[nx]|ut|v[at]|w[aivy])+)\.domain\.com$"/>
    </conditions>
    <action type="Rewrite" url="/LocationMatch.html?c={C:1}s={C:2}"/>
</rule>

Upvotes: 2

Views: 312

Answers (1)

ruakh
ruakh

Reputation: 183584

You don't explain what problems you're having, but here are a few things to look at:

<match url="^.*(/$|$)"/>

this matches any string that doesn't contain newlines. That's probably not what you want. It will probably cause an infinite redirect-loop, because the URL that you're rewriting to will also match this regex. (Does IIS allow the same rewrite rule to be matched multiple times?)

Also, this is a smaller point, but in this:

?c={C:1}s={C:2}

it looks like you're missing an ampersand & between your query-string parameters.

Upvotes: 2

Related Questions