2

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>
Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
Jason
  • 85
  • 1
  • 1
  • 8

1 Answers1

2

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.

ruakh
  • 175,680
  • 26
  • 273
  • 307
  • hmm good question about the IIS thing, unsure if it matches multiple times. I was thinking the problem was related to my regex grouping, ^( ... Ive tried using regexr, and generating a new one, you'd think this would be a common issue? lol not much online..(why im here right?) ... .the problem im having is that this rewrite rule redirects me to the main page versus the custom one, wonderin if maybe thats the issue with the rule match. I want to check all requests for city.state.domain.com ... and ive written a city rule, but now i need a combined city / state rule. – Jason Jan 28 '12 at 20:04
  • See for more information on what I was trying to do at [link]http://stackoverflow.com/questions/9069938/split-regular-expression-into-2-capture-groups[/link] – Jason Jan 31 '12 at 15:21