Forum Discussion

Gary_Bristol_19's avatar
Gary_Bristol_19
Icon for Nimbostratus rankNimbostratus
Oct 08, 2015

I am really bad at this,

I am attempting to incorporate some previous examples into a iRule that will do the following as I can't see to get a Data group File to work. what i need to do is the following I have attempted to use an external data group file and an internal Data group file and the irule never picks up the second variable. so I am attempting to do this short list with a all inclusive iRule.

lms.ou.edu redirect to survey.ou.edu redirect to tutoring.ou.edu redirect to http://www.ou.edu/graduatesooner/resources/tutoring.html,

webapps.ou.edu/alerts redirect to http://www.ou.edu/ouit/help/alerts, webapps.ou.edu/elections redirect to https://orgsync.com/122675/chapter, webapps.ou.edu/hsp redirect to http://www.ou.edu/hsp.html,

webapps.ou.edu/it redirect to http://www.ou.edu/ouit, webapps.ou.edu/it/faculty redirect to http://www.ou.edu/ouit, webapps.ou.edu/it/staff redirect to http://www.ou.edu/ouit, webapps.ou.edu/it/students redirect to http://www.ou.edu/ouit,

webapps.ou.edu/it/identity redirect to http://www.ou.edu/content/ouit/security/top10/safeguard_your_personalinformation.html, webapps.ou.edu/it/newstudents redirect to http://www.ou.edu/ouit/new.html,

webapps.ou.edu/security redirect http://www.ou.edu/ouit/security, webapps.ou.edu/studentservices redirect to http://www.ou.edu/ouit/aud/students, webapps.ou.edu/students redirect http://www.ou.edu/ouit/aud/students, webapps.ou.edu/support redirect to http://www.ou.edu/content/ouit/help/personal.html,

webapps.ou.edu/virtualtour redirect www.ou.edu/map,

webapps.ou.edu/it/phonerates := pool,nor-it-webapps_pool, webapps.ou.edu := pool,nor-it-webapps_pool, webapps.ou.edu/flex2gateway := pool,nor-it-webapps_pool, webapps.ou.edu/supporttool := pool,nor-it-webapps_pool,

what I have attempted to use for the first part is ; but it always seems to go to www.ou.edu/ouit, once it gets to anything below /it

 when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
  "webapps.ou.edu" {
    switch -glob [string tolower [HTTP::uri]] {
      "/alerts" {
        HTTP::redirect "http://www.ou.edu/ouit/help/alerts"
        }
      "/elections*" {
        HTTP::redirect "https://orgsync.com/122675/chapter"
        }
      "/hsp*" {
        HTTP::redirect "http://www.ou.edu/hsp.html"
        }
      "/it*" {
        HTTP::redirect "http://www.ou.edu/ouit"
        }
      "/it/faculty*" {
        HTTP::redirect "http://www.ou.edu/ouit"
        }
        "/it/staff*" {
        HTTP::redirect "http://www.ou.edu/ouit"
        }
        "/it/students*" {
        HTTP::redirect "http://www.ou.edu/ouit"
        }
        "/it/identity*" {
        HTTP::redirect "http://www.ou.edu/content/ouit/security/top10/safeguard_your_personalinformation.html"
        }
        "/it/newstudents*" {
        HTTP::redirect "http://www.ou.edu/ouit/new.html"
        }
      }
    }
  }
}

10 Replies

  • Have you tried reordering the list? Something like this? Sounds like it's matching on

    /it/*
    first since it's higher in the list, so any sub URIs won't match as expected...

    when HTTP_REQUEST {
        switch [string tolower [HTTP::host]] {
            "webapps.ou.edu" {
                switch -glob [string tolower [HTTP::uri]] {
                    "/alerts" {
                        HTTP::redirect "http://www.ou.edu/ouit/help/alerts"
                    }
                    "/elections*" {
                        HTTP::redirect "https://orgsync.com/122675/chapter"
                    }
                    "/hsp*" {
                        HTTP::redirect "http://www.ou.edu/hsp.html"
                    }
                    "/it/faculty*" {
                        HTTP::redirect "http://www.ou.edu/ouit"
                    }
                    "/it/staff*" {
                        HTTP::redirect "http://www.ou.edu/ouit"
                    }
                    "/it/students*" {
                        HTTP::redirect "http://www.ou.edu/ouit"
                    }
                    "/it/identity*" {
                        HTTP::redirect "http://www.ou.edu/content/ouit/security/top10/safeguard_your_personalinformation.html"
                    }
                    "/it/newstudents*" {
                        HTTP::redirect "http://www.ou.edu/ouit/new.html"
                    }
                    "/it*" {
                        HTTP::redirect "http://www.ou.edu/ouit"
                    }
                }
            }
        }
    }
    
  • So here is what i was able to come up with, not pretty, but i still have problems with these url's falling through properly.

    webapps.ou.edu/it/phonerates := pool,nor-it-webapps_pool,
    webapps.ou.edu :=  pool,nor-it-webapps_pool,
    webapps.ou.edu/flex2gateway := pool,nor-it-webapps_pool,
    webapps.ou.edu/supporttool :=  pool,nor-it-webapps_pool,
    
            when HTTP_REQUEST {
    
          set lhost [string tolower [HTTP::host]]
          set lpath [string tolower [HTTP::path]]
    
          if { $lhost equals "lms.ou.edu"  } {
              HTTP::redirect "http://learn.ou.edu"
            }
              if { $lhost equals "survey.ou.edu"  } {
              HTTP::redirect "https://ousurvey.qualtrics.com"
            }
            if { $lhost equals "tutoring.ou.edu"  } {
              HTTP::redirect "http://www.ou.edu/graduatesooner/resources/tutoring.html"
            }
            if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/alerts") }{
              HTTP::redirect "http://www.ou.edu/ouit/help/alerts"
            }
                if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/elections") }{
              HTTP::redirect "https://orgsync.com/122675/chapter"
            }
             if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/hsp") }{
              HTTP::redirect "http://www.ou.edu/hsp.html"
            }
              if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/it/faculty") }{
              HTTP::redirect "http://www.ou.edu/ouit"
            }
            if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/it/staff") }{
              HTTP::redirect "http://www.ou.edu/ouit"
            }
             if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/it/students") }{
              HTTP::redirect "http://www.ou.edu/ouit"
            }
             if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/it/identity") }{
              HTTP::redirect "http://www.ou.edu/content/ouit/security/top10/safeguard_your_personalinformation.html"
            }
               if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/it/newstudents") }{
              HTTP::redirect "http://www.ou.edu/ouit/new.html"
            }
                 if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/it") }{
              HTTP::redirect "http://www.ou.edu/ouit"
            }
              if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/security") }{
              HTTP::redirect "http://www.ou.edu/ouit/security"
            }
          if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/studentservices") }{
              HTTP::redirect "http://www.ou.edu/ouit/aud/students"
            }
              if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/students") }{
              HTTP::redirect "http://www.ou.edu/ouit/aud/students"
            }
            if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/support") }{
              HTTP::redirect "http://www.ou.edu/content/ouit/help/personal.html"
            }
                if { $lhost equals "webapps.ou.edu"  } {
            if { ($lpath starts_with "/virtualtour") }{
              HTTP::redirect "http://www.ou.edu/map"
            }
        }
        }
        }
        }
        }
        }
        }
        }
        }
        }
        }
        }
        }
        }
        }
    
    • Brad_Parker's avatar
      Brad_Parker
      Icon for Cirrus rankCirrus
      No offense, but eww. I'm working on cleaning this up a bit for you. All those IFs are very inefficient.
    • Michael_Jenkins's avatar
      Michael_Jenkins
      Icon for Cirrostratus rankCirrostratus
      With all the if statements, you'll likely run into multiples being valid as you traverse down. Did you try the code I added above? Did that help at all? It seemed to work when testing it on the BIG-IP through tclsh.
  • what would i do using the "switch" function if i had multiple host, notice the top three lines...

     

  • Give this a try. Its a lot like Michael J's, but a little tweaking:

    when HTTP_REQUEST {
        switch [string tolower [HTTP::host]] {
            "lms.ou.edu" { HTTP::redirect "http://learn.ou.edu" }
            "survey.ou.edu" { HTTP::redirect "https://ousurvey.qualtrics.com" }
            "tutoring.ou.edu" { HTTP::redirect "http://www.ou.edu/graduatesooner/resources/tutoring.html" }
            "webapps.ou.edu" {
                switch -glob [string tolower [HTTP::uri]] {
                    "/alerts*" { HTTP::redirect "http://www.ou.edu/ouit/help/alerts" }
                    "/elections*" { HTTP::redirect "https://orgsync.com/122675/chapter" }
                    "/hsp*" { HTTP::redirect "http://www.ou.edu/hsp.html" }
                    "/it/identity*" { HTTP::redirect "http://www.ou.edu/content/ouit/security/top10/safeguard_your_personalinformation.html" }
                    "/it/newstudents*" { HTTP::redirect "http://www.ou.edu/ouit/new.html" }
                    "/it*" { HTTP::redirect "http://www.ou.edu/ouit" }
                    "/security*" { HTTP::redirect "http://www.ou.edu/ouit/security" }
                    "/studentservices*" { HTTP::redirect "http://www.ou.edu/ouit/aud/students" }
                    "/students*" { HTTP::redirect "http://www.ou.edu/ouit/aud/students" }
                    "/support*" { HTTP::redirect "http://www.ou.edu/content/ouit/help/personal.html" }
                    "/virtualtour*" { HTTP::redirect "http://www.ou.edu/map" }
                }
            }
        }
    }
    

    You could also use a LTM policy that uses "Best-Match" rather han "First-Match" is you wanted to go that route.

  • Yeah except for the missing redirect statement on the last line that should work and is alot cleaner. thanks