« Previous Next »

Thread: Help! Regular Expressions

Last post 05-18-2009 9:04 AM by aplevine. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 05-15-2009, 5:04 PM

    • aplevine
    • Not Ranked
    • Joined on 08-08-2006, 9:04 AM
    • North Carolina
    • Posts 8

    Help! Regular Expressions

    Here is the scenario.  We have ARR receiving requests for 2 distinct hostnames.  We'll call then http://WEBAPP1 and http://WEBAPP2.  Both host names have the same IP and resolve to the same ARR server.

    WEBAPP1 and WEBAPP2 have 2 servers behind them.  In ARR I have 4 web farms. 

    • WEBAPP1A
    • WEBAPP1B
    • WEBAPP2A
    • WEBAPP2B

    In my URL Rewrite rules, at the bottom is WEBAPP1A with a * wildcard.  Everything that comes in to WEBAPP1 goes to WEBAPP1A by default.

    The next rule is WEBAPP1B.  It is a * wildcard rule with conditions.  If you go to WEBAPP1/condition.htm (this is the REQUEST_URI in the condition) then you get routed to server WEBAPP1B.  Otherwise you get routed to server WEBAPP1A. 

     Now this same ARR hosts WEBAPP2 - different host name.

    I can create the next rule as a * wildcard and add a condition with HTTP_HOST to qualify the host name as WEBAPP2.  This would be the default location for WEBAPP2 urls.

    Now when I to route to WEBAPP2B, and I want to have multiple REQUEST_URIs in the conditions, I need to qualify the rule pattern with a regular expression to single out the host name.  So if I want WEBAPP2/condition.htm to go to WEBAPP2B, I need to know how to write this expression.  There doesn't seem to be a way to do this with * wildcards.

     Any and all help is greatly appeciated.

    Alan Levine
    Progress Energy - Raleigh, NC

  • 05-15-2009, 8:14 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 3:38 PM
    • Redmond, WA
    • Posts 661

    Re: Help! Regular Expressions

    Could you post your current rules and point out the rule where you want to modify the pattern?

    http://ruslany.net
  • 05-17-2009, 11:37 AM In reply to

    • aplevine
    • Not Ranked
    • Joined on 08-08-2006, 9:04 AM
    • North Carolina
    • Posts 8

    Re: Help! Regular Expressions

    Thanks for the reply!  Here are the current rules. The top-most rule should be invoked for the host name WEBAPPUAT with conditions for specific applications.  Using a wildard rule, I tried to qualify the hostname with *webappuat* or http://webappuat*, but this did not work. 

     -Alan Levine 

     <rewrite>
                <globalRules>
                    <clear />
                    <rule name="ARR_Core2Uat_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*webappuat*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="/hello2.txt" />
                        </conditions>
                        <action type="Rewrite" url="http://Core2Uat/{R:0}" />
                    </rule>
                    <rule name="ARR_Core1Uat_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{HTTP_HOST}" pattern="webappuat" />
                        </conditions>
                        <action type="Rewrite" url="http://Core1Uat/{R:0}" />
                    </rule>
                    <rule name="ARR_Core2Int_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="/hello2.txt" />
                            <add input="{REQUEST_URI}" pattern="/testtest/*" />
                        </conditions>
                        <action type="Rewrite" url="http://Core2Int/{R:0}" />
                    </rule>
                    <rule name="ARR_Core1Int_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAll" />
                        <action type="Rewrite" url="http://Core1Int/{R:0}" />
                    </rule>
                </globalRules>
            </rewrite>

  • 05-17-2009, 8:56 PM In reply to

    • aplevine
    • Not Ranked
    • Joined on 08-08-2006, 9:04 AM
    • North Carolina
    • Posts 8

    Re: Help! Regular Expressions

    not sure if you received my reply with my rules. please let me know and I will reply again if needed.

    <globalRules>
                    <clear />
                    <rule name="ARR_Core2Uat_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*webappuat*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="/hello2.txt" />
                        </conditions>
                        <action type="Rewrite" url="http://Core2Uat/{R:0}" />
                    </rule>
                    <rule name="ARR_Core1Uat_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{HTTP_HOST}" pattern="webappuat" />
                        </conditions>
                        <action type="Rewrite" url="http://Core1Uat/{R:0}" />
                    </rule>
                    <rule name="ARR_Core2Int_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="/hello2.txt" />
                            <add input="{REQUEST_URI}" pattern="/testtest/*" />
                        </conditions>
                        <action type="Rewrite" url="http://Core2Int/{R:0}" />
                    </rule>
                    <rule name="ARR_Core1Int_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAll" />
                        <action type="Rewrite" url="http://Core1Int/{R:0}" />
                    </rule>
                </globalRules>

  • 05-18-2009, 9:04 AM In reply to

    • aplevine
    • Not Ranked
    • Joined on 08-08-2006, 9:04 AM
    • North Carolina
    • Posts 8

    Re: Help! Regular Expressions

    <globalRules>
                    <clear />
                    <rule name="ARR_Core2Uat_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*webappuat*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="/hello2.txt" />
                        </conditions>
                        <action type="Rewrite" url="http://Core2Uat/{R:0}" />
                    </rule>
                    <rule name="ARR_Core1Uat_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{HTTP_HOST}" pattern="webappuat" />
                        </conditions>
                        <action type="Rewrite" url="http://Core1Uat/{R:0}" />
                    </rule>
                    <rule name="ARR_Core2Int_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="/hello2.txt" />
                            <add input="{REQUEST_URI}" pattern="/testtest/*" />
                        </conditions>
                        <action type="Rewrite" url="http://Core2Int/{R:0}" />
                    </rule>
                    <rule name="ARR_Core1Int_loadbalance" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAll" />
                        <action type="Rewrite" url="http://Core1Int/{R:0}" />
                    </rule>
                </globalRules>

  • 05-18-2009, 10:35 AM In reply to

    • aplevine
    • Not Ranked
    • Joined on 08-08-2006, 9:04 AM
    • North Carolina
    • Posts 8

    Re: Help! Regular Expressions

    Ruslan,

    I've added my rules to my last reply.  Does it make sense what I am trying to do?

    Thanks in advance,
    Alan Levine

Page 1 of 1 (6 items)
Microsoft Communities