Forum Discussion
Regexp question
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.
3 Replies
- Kevin_Stewart
Employee
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 } } - soymanue
Nimbostratus
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/ - Kevin_Stewart
Employee
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
/
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
