I want to build and iRule witch “SWITCH” command to make an URI based redirection.
If we have http://www.mydomain.com/URI y would need to redirect this way
if URI is “/marketing” or “/marketing/” → Redirection 1
if URI is “/accounting” or “/accounting/” → Redirection 2
if URI is “/humanresources” or “/humanresources/” → Redirection 2
How would you check with regexp if a string is client1, client1/ . Something like client1[ "/ ", ]
Even better How would you check this:
“/MARKETING”
“/MARKETING/”
“/MARKETING/EN”
“/MARKETING/EN/”
“/HUMANRESURCES”
“/HUMANRESURCES/”
“”/HUMANRESURCES/EN"
“/HUMANRESURCES/EN/”
I was thinking abut inserting a final “/” if the string doesn’f end with one.
You don’t even need a regex for something like this. Just use the -glob option of the switch command:
switch -glob [string tolower [HTTP::uri]] {
"/marketing*" { pool marketing_pool }
"/accounting*" { pool accounting_pool }
"/humanresources*" { pool hr_pool }
default { pool default_pool }
}
Hi
Thanks for your help but it’s a bit more complicated:
Department => 16 different values
Language => 4 different values
/Department → /marketing/es/particulares/
/Department/ → /marketing/es/particulares/
/Department/Language > > /marketing/en/particulares/
/Department/Language/ → /marketing/en/particulares/
/Department/Language/ → no reditection
marketing/sp/
I think the switch -glob would still probably work, as long as you search from most specific to least specific.
/department/language/
/department/language
/department/
/department
/