Alex_Pintel
Nov 22, 2022Nimbostratus
iRule exclude URI
I am fairly new to iRules so any help greately appreciated.
What is correct syntax to exclude URI "/abc/Web123/cde/forum123/ from receiving HTTP code 200 and the message "123456789"? Is the exclamation mark a orrect synatx to exclude URI?
Here is iRule
when HTTP_REQUEST {
set http_path [ string tolower [HTTP::path]]
if { ! ($http_path starts_with "/abc/Web123/cde/forum123") } {
HTTP::respond 200 content "
<html>
<head>
<title></title>
</head>
<body>
123456789
</body>
</html>
"
}
}
Thank you for any assistamce you can provide.
To negate starts_with I would use the not operator:
https://clouddocs.f5.com/api/irules/not.html
when HTTP_REQUEST { if { not ([HTTP::uri] starts_with "/abc") } { # do something ... } else { # do something else... } }
For excluding the exact path, you can go with the "ne" operator