Forum Discussion
Trouble with APM Irule
I am new to writing iRules and the switch function.. I am having trouble using the switch and a not statement to check if a cookie exists and then run the switch on that condition.. I know i am using the wrong syntax, i am trying to have an irule that checks if a cookie is present, then determines if a certian URL is accessed. If a URL is accessed and there is no cookie present, then APM would disable. Any help would be appreciated.
when HTTP_REQUEST {
if {
not ( [HTTP::cookie exists MRHSession] ) {
switch -glob [string tolower [HTTP::path]]{
"/uri1" -
"/uri2" {
ACCESS::disable
}
}
} else {
ACCESS::enable
return
}
}
}
3 Replies
- Cory_50405
Noctilucent
What behavior are you seeing from the iRule? I would think something like this should work:
when HTTP_REQUEST { if { ! ( [HTTP::cookie exists MRHSession] ) } { switch -glob [string tolower [HTTP::path]]{ "/uri1*" - "/uri2*" { ACCESS::disable } } } else { ACCESS::enable return } } - sbrudolf1_14757
Nimbostratus
I get error: [wrong args] when trying to save that, i have the same problems when trying to use a datagroup list.
I want APM to be disabled if a certain URL is accessed but only if an APM session has not already been established... I am debating on just writing something with a bunch of if statements.
- Cory_50405
Noctilucent
It appears to be something about the formatting of your switch statement. I got this one to load:
when HTTP_REQUEST { if { ! [HTTP::cookie exists "MRHSession"] } { switch -glob [string tolower [HTTP::path]] { "/uri1*" - "/uri2*" { ACCESS::disable } } } else { ACCESS::enable return } }
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