Forum Discussion
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
- Michael_Jenkins
Cirrostratus
Have you tried reordering the list? Something like this? Sounds like it's matching on
first since it's higher in the list, so any sub URIs won't match as expected.../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/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" } } } } } - Gary_Bristol_19
Nimbostratus
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
Cirrus
No offense, but eww. I'm working on cleaning this up a bit for you. All those IFs are very inefficient. - Michael_Jenkins
Cirrostratus
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.
- Gary_Bristol_19
Nimbostratus
what would i do using the "switch" function if i had multiple host, notice the top three lines...
- Brad_Parker
Cirrus
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.
- Gary_Bristol_19
Nimbostratus
Yeah except for the missing redirect statement on the last line that should work and is alot cleaner. thanks
- Brad_Parker
Cirrus
Fixed it, ;-) - Gary_Bristol_19
Nimbostratus
yes, thank you for the Clean Code. - Gary_Bristol_19
Nimbostratus
now if i could just get the External Data Group file to work, i could feel comfortable about the 700+ url checks i will need to do.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com