Help with RegEx
I am having some difficulty forming the correct syntax (or regex) for an irule.
I need to block some specific URI's if they come from a specific data group. The logic works, but the regex doesn't.
For example. I need to block any URI that has /admin or /admin/ or /user or /user/ BUT (and this is where it's not working) if the URI= /user-experience then it needs to work.
I've used REGEX that looks like
elseif {([HTTP::uri] matches_regex "^(/admin/|/user/|/?q=admin|/?q=admin|/?q=user|/?q=user) and ([class match [IP::client_addr] equals block_ip])} {
And I've used a bunch of different "starts_with" and "equals" but strangely enough whenever I block "user" it blocks user-experience. Even if I use the "equals" URI. Which I don't understand b/c /user-experience doesn't equal /user.
I'm sure there is something simple here...any help would be appreciated.
Thanks in advance
regex in iRule equals bad news. Try something like this:
elseif { [class match [IP::client_addr] equals block_ip] }{ switch -glob [string tolower [HTTP::uri]] { "/user-experience*" { return } "/user*" - "/admin*" { reject } default { return } } }