Forum Discussion

jbergeron_10592's avatar
jbergeron_10592
Icon for Nimbostratus rankNimbostratus
Jan 24, 2008

Unable to make this work - Help Please

Good Morning -

 

 

Where am I going wrong? After struggling through this for the past 3 days, I am at my wits end. We are trying to convert our 4.5 rules to 9.4 and to this point have been completely unsuccessful. If anyone out there could help me, it would be much appreciated!

 

 

Here are the two rules I am trying to convert (and my feable attempts as well):

 

 

XYZ Redirect -

 

 

if (not (http_host == "www.xyz.com")) {

 

if (http_host == "mobile.xyz.com") {

 

redirect to "http://www.xyz.com/mobile"

 

}

 

else {

 

if (http_uri matches_regex "xyzfreeconversion.asp" or http_uri matches_regex "getconversion.asp" or http_uri matches_regex "whoami.asp") {

 

use pool LAX_ORIGIN_SERVERS

 

}

 

else {

 

redirect to "http://www.xyz.com/%u"

 

}

 

}

 

}

 

else {

 

use pool LAX_ORIGIN_SERVERS

 

}

 

 

 

 

My attempt -

 

 

 

when HTTP_REQUEST {

 

if {not [HTTP::host] == "www.xyz.com" } {

 

if { [HTTP::host] == "mobile.xyz.com" } {

 

HTTP::redirect "http://www.xyz.com/mobile"

 

}

 

else {

 

if { [http_uri] matches_regex "xyzfreeconversion.asp" or [http_uri] matches_regex "getconversion.asp" or [http_uri] matches_regex "whoami.asp" } {

 

pool LAX_ORIGIN_SERVERS

 

}

 

else {

 

HTTP::redirect "http://www.xyz.com/%u"

 

}

 

}

 

}

 

else {

 

pool LAX_ORIGIN_SERVERS

 

}

 

}

 

 

 

 

Second Rule -

 

 

if (not (http_host == "www.xyzfree.net")) {

 

if (http_host == "www.xyzfree.com" or http_host == "www.freexyz.com" or http_host == "www.freexyz.net") {

 

redirect to "http://www.xyz.com/"

 

}

 

else {

 

redirect to "http://www.xyzfree.net/%u"

 

}

 

}

 

else {

 

use pool xyzFree

 

}

 

 

 

My attempt -

 

 

when HTTP_REQUEST {

 

if {not [HTTP::host] == "www.xyzfree.net" } {

 

if { [HTTP::host] == "www.xyzfree.com" or [HTTP::host] == "www.freexyz.com" or [HTTP::host] == "www.freexyz.net" } {

 

HTTP::redirect "http://www.xyz.com/"

 

}

 

else {

 

HTTP::redirect "http://www.xyzfree.net/%u"

 

}

 

}

 

else {

 

pool xyzFree

 

}

 

if {not [HTTP::host] == "www.xyz.com" } {

 

}

 

}

 

 

Thanks in advance for your assistance!

 

 

JB

 

 

 

 

4 Replies

  • I'm not sure I have all your if/else logic right, so check it. Also, I substituted contains for matches_regex to save resources, but this may not meet your needs.

    1st rule:

    
    when HTTP_REQUEST {
      if {not ([HTTP::host] eq "www.xyz.com") } {
        if { [HTTP::host] eq "mobile.xyz.com" } {
          HTTP::redirect "http://www.xyz.com/mobile"
    } elseif { ([HTTP::uri] contains "xyzfreeconversion.asp") \
    or ([HTTP::uri] contains "getconversion.asp") \
    or ([HTTP::uri] contains "whoami.asp") } {
    pool LAX_ORIGIN_SERVERS
    } else { HTTP::redirect http://www.xyz.com/[HTTP::uri] }
      } else { pool LAX_ORIGIN_SERVERS }
    }

    If this works for you, try adjusting the second rule yourself, and if you get stuck, post back.
  • The first one works...but the one I tried naturally didn't...I have somewhat of an inverse Midas touch these days...

     

     

     

    Your help would be appreciated.

     

     

     

     

    when HTTP_REQUEST {

     

    if {not ([HTTP::host] equals "www.xyzfree.net") } {

     

    if { ([HTTP::host] equals "www.xyzfree.com") } {

     

    HTTP::redirect "http://www.xyz.com/"

     

    } elseif { ([HTTP::host] equals "www.freexyz.com") \

     

    or ([HTTP::host] equals "www.freexyz.net") } {

     

    HTTP::redirect "http://www.xyz.com/"

     

    } else { HTTP::redirect http://www.xyzfree.net/[HTTP::uri] }

     

    } else { pool xyzFree }

     

    }

     

     

    Thanks,

     

    JB
  • I think this is what you're after in the same context as your v4 rule:

    
    when HTTP_REQUEST {
      if { not ([HTTP::host] eq "www.xyzfree.net") } {
        if { ([HTTP::host] eq "www.xyzfree.com") \
    or ([HTTP::host] eq "www.freexyz.com") \
    or ([HTTP::host] eq "www.freexyz.net") } {
          HTTP::redirect http://www.xyz.com
        } else { HTTP::redirect http://www.xyzfree.net/[HTTP::uri] }
      }
      else { pool xyzFree }
    }

    Check through the logic, but I think this is the same thing, only a little more readable (to me):

    
    when HTTP_REQUEST {
      if { [HTTP::host] eq "www.xyzfree.net" } {
        pool xyzFree
      } elseif { ([HTTP::host] eq "www.xyzfree.com") \
    or ([HTTP::host] eq "www.freexyz.com") \
    or ([HTTP::host] eq "www.freexyz.net") } {
          HTTP::redirect http://www.xyz.com
      } else {  HTTP::redirect http://www.xyzfree.net/[HTTP::uri] }
    }