Forum Discussion

Gary_Bristol_19's avatar
Gary_Bristol_19
Icon for Nimbostratus rankNimbostratus
Aug 25, 2015

need multi layer redirect

I quess I still haven't gotten the hang of writing these rules.

 

here is what i need to be able to accomplish

 

needhelp.ou.edu/library => https://ounew.service-now.com/forms/walkin_bizzell.do needhelp.ou.edu/couch => https://oudev.service-now.com/forms/walkin_couch.do needhelp.ou.edu/el => https://oudev.service-now.com/forms/walkin_el.do needhelp.ou.edu/oneu => https://oudev.service-now.com/forms/walkin_oneu.do

 

"needhelp.ou.edu" only should go to http://itscnorman.ou.edu/contact/

 

when HTTP_REQUEST { if { [HTTP::host header] is needhelp.ou.edu and {http::uri starts_with “/library” } { HTTP::redirect “https://ounew.service-now.com/forms/walkin_bizzell.do” if { [HTTP::host header] is needhelp.ou.edu and {http::uri starts_with “/couch” } { HTTP::redirect “https://oudev.service-now.com/forms/walkin_couch.do” if { [HTTP::host header] is needhelp.ou.edu and {http::uri starts_with “/el” } { HTTP::redirect “https://oudev.service-now.com/forms/walkin_el.do ” if { [HTTP::host header] is needhelp.ou.edu and {http::uri starts_with “/oneu” } { HTTP::redirect “https://oudev.service-now.com/forms/walkin_oneu.do” if { [HTTP::host header] is “needhelp.ou.edu” } { HTTP::redirect "http://itscnorman.ou.edu/contact"} } } } } } }

 

2 Replies

  • I would use a switch command as it's a bit more efficient, also for posting code here use the Preformatted code button on the irule text so it's more readable,

     

    cheers

     

    when HTTP_REQUEST {
    switch [string tolower [HTTP::host]] {
      "needhelp.ou.edu" {
        switch -glob [string tolower [HTTP::uri]] {
          "/" {
            HTTP::redirect "http://itscnorman.ou.edu/contact/"
            }
          "/library*" {
            HTTP::redirect "https://ounew.service-now.com/forms/walkin_bizzell.do"
            }
          "/couch*" {
            HTTP::redirect "https://oudev.service-now.com/forms/walkin_couch.do"
            }
          "/el*" {
            HTTP::redirect "https://oudev.service-now.com/forms/walkin_el.do"
            }
          "/oneu*" {
            HTTP::redirect "https://oudev.service-now.com/forms/walkin_oneu.do"
            }
          }
        }
      }
    }
  • Yes that worked fine. I was also contemplating using an internal Data Group, but I couldn't get the needhelp.ou.edu/ to redirect.