Forum Discussion
switch -glob issue with URI tolower string
Hi Guys, I expect this irule to be working for me based on my URI but it is not working. it only supports lowercases and can't detect anything in Capital like Lion or TIGER. Please help if you have any idea.
when HTTP_REQUEST { switch -glob [string tolower [HTTP_uri]] { "/lion" { pool test1 member 1.1.1.1:8080 } "/tiger" { pool test1 member 1.1.1.2:8080 } "/mouse*" { pool test1 member 1.1.1.3:8080 } default { HTTP::redirect "/tiger" } } }
- JGCumulonimbus
You had a typo; also I'd use [HTTP::path] instead.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/lion" { pool test1 member 1.1.1.1 8080 } "/tiger" { pool test1 member 1.1.1.2 8080 } "/mouse*" { pool test1 member 1.1.1.3 8080 } default { HTTP::redirect "/tiger" } } }
- Stanislas_Piro2Cumulonimbus
The problem when you anonymize the code is to check if the code you applied is correct!
if you convert URI or PATH (as suggested Jie) to lowercase, the switch condition must be lowercase.
for example :
when HTTP_REQUEST { switch -glob [string tolower [HTTP_uri]] { "/lion" { pool test1 member 1.1.1.1:8080 } --> will match /lion /Lion /LION /LioN "/Tiger" { pool test1 member 1.1.1.2:8080 } --> will never match because you compare a lowercase string with a string with a uppercase character "/mouse*" { pool test1 member 1.1.1.3:8080 } --> will match /mouse /Mouse / /MOUSE /mousekdjghflh /MOuse/images/front.png default { HTTP::redirect "/tiger" } } }
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