Forum Discussion

Ken_Norris_1353's avatar
Ken_Norris_1353
Icon for Nimbostratus rankNimbostratus
Oct 09, 2013

confirm if iRule will work or not....

can someone please tell me if this iRule will redirect to www.comehereinstead.com if nothere1, nothere2, nothere3, nothere4 are requested? THANKS. (I'm an F5/iRule newbie as of 2 weeks now).

 

when HTTP_REQUEST { if { [HTTP::host] equals "http://nothere1.com"} { HTTP::redirect "http://comehereinstead.com" } elseif { [HTTP::host] equals "http://www.nothere2.com"} { HTTP::redirect "http://comehereinstead.com" } elseif { [HTTP::host] equals "http://nothere3.com"} { HTTP::redirect "http://comehereinstead.com" } elseif { [HTTP::host] equals "http://www.nothere4.com"} { HTTP::redirect "http://comehereinstead.com" } }

 

1 Reply

  • Pleas try this:

    when HTTP_REQUEST {
        switch [string tolower [HTTP::host]] {
            "nothere1.com" -
            "nothere2.com" -
            "nothere3.com" -
            "nothere4.com" {
                HTTP::redirect "http://comehereinstead.com"
            }
        }
    }
    

    The [HTTP::host] command will only capture the host name and not the protocol (ie. "http://").