Forum Discussion
Brian_Yeager_12
Nimbostratus
Jan 26, 2009Does Not Equal String Question
I have been working on this (sanitized a bit).
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/whateverthisendsupbeing") and
([IP::client_addr] != "xxx.xxx.xxx.xxx") } {
HTTP::redirect https://www.chat.com
} elseif { ([HTTP::uri] contains "/whateverthisendsupbeing2") and
([IP::client_addr] != "xxx.xxx.xxx.xxx") } {
HTTP::redirect https://www.chat.com
} else {
pool Chat_Pool
}
}
Basically the first two if's check if there's is the URL/URI contain /whateverthisendsupbeing and /whateverthisendsupbeing2. If it does, but is not coming from a certain IP address (xxx.xxx.xxx.xxx), then it forwards them to the root URL (which sends them back through the iRule and forwards them to Chat_Pool.
Otherwise, it lets them continue on their way to Chat_Pool.
I am not sure on the syntax for my != check. I looked through the wiki but couldn't find an example similar to this.
Could someone please take a look at it for me?
2 Replies
- Brian_Yeager_12
Nimbostratus
Also, is there a way to represent the client addr as a range of IP addresses instead of just one address? So like, xxx.xxx.xxx.0/24.
Thanks - hoolio
Cirrostratus
You can use the IP::addr command (Click here) to evaluate single IP addresses or a single subnet against another single IP address or single subnet.
You can perform a logical not using ! or "not":
Check if x isn't equal to 2
if { ! (x==2) }{
or in iRules:
Check if x isn't equal to 2
if { not (x==2) }{
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects