Forum Discussion

shipszky_319427's avatar
shipszky_319427
Icon for Nimbostratus rankNimbostratus
Oct 12, 2017

help on uri redirect w/ filtered IP's

I'm searching for a way to filter IP's while doing a uri redirect any thoughts? I do have corresponding data groups, IE list "d" and list "e"

when HTTP_REQUEST {
   if { ([string tolower [HTTP::uri]] contains "/d")
      }{ HTTP::redirect "https://abc.de.com//site/d/"}
   if { ([string tolower [HTTP::uri]] contains "/e")
      }{ HTTP::redirect "https://abc.de.com//site/e/"}
}

Popossibly something along the lines of

if {([string tolower [HTTP::uri]] contains "/d") and { [class match [IP::client_addr] equals d] }

Thanks in advance for the help.

1 Reply

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    If you already have a IP datagroup then.. try this

     

    when HTTP_REQUEST {

     

    if { [class match [IP::client_addr] equals IP_group] && [string tolower [HTTP::uri]] contains "/d" } {

     

    HTTP::redirect "https://abc.de.com[HTTP::uri]"

     

    }

     

    elseif { [class match [IP::client_addr] equals IP_group] && [string tolower [HTTP::uri]] contains "/e" } {

     

    HTTP::redirect "https://abc.de.com[HTTP::uri]"

     

    }

     

    }

     

    Please note that uri path that contains is only redirected to path before the , everything after will be sliced away. In your case, it will only redirect to https://abc.de.com/ since you have a symbol after that.

     

    Hash sign is treated as fragment and path after is never sent to server by any browser. Hope this helps!